-7
我可以從主類以編程方式添加ImageView。但是我不能從一個子類中做到這一點。 當我嘗試ImageView iv = new ImageView(this)
我得到一個錯誤 ImageView的(android.content.Contex)在ImageView的不能適用於(... MainActivity.MySubclass)不能添加ImageView的子類
代碼:
public class MainActivity extends Activity {
...
class MySubclass
{
ImageView iv;
MySubclass(View v) // create an object from onClick method
{
iv = new ImageView(this);
}
} // end of subclass
} // end of main
提供代碼你做了什麼 –
爲什麼你甚至在子類中添加圖像視圖? – hehe
如果你是Android新手,[這是很好的學習東西](https://github.com/codepath/android_guides/wiki) – hehe