0
我在應用程序中動態添加滾動視圖中的圖像按鈕,但我無法查看我的圖像按鈕。任何人都可以幫助。 這裏是我的代碼 -在滾動視圖中動態添加ImgeButton
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.activity_main, null);
scrollview=(ScrollView)findViewById(R.id.scrollview);
LinearLayout ll =(LinearLayout)findViewById(R.id.scrollinear);
ImageButton button = new ImageButton(this);
button.setBackgroundResource(R.drawable.travel);
ll.addView(button);
setContentView(v);
這裏是我的activity_main.xml中
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/scrollinear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFCC99"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
thanks..it工作。 – user1859771