私はAndroidの初心者です。imageViews を線形レイアウトに動的に追加し、各画像を個別にアニメーション化する必要があるという要件があります。
imageViews を線形レイアウトに動的に追加する方法を知りません。助けてください。
ありがとう
私はAndroidの初心者です。imageViews を線形レイアウトに動的に追加し、各画像を個別にアニメーション化する必要があるという要件があります。
imageViews を線形レイアウトに動的に追加する方法を知りません。助けてください。
ありがとう
これを見る
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.rainbow);
ImageView tv1 = new ImageView (this);
tv1.setImageresorce(R.drawable.image1);
ImageView tv2 = new ImageView (this);
tv2.setImageresorce(R.drawable.image2);
ImageView tv3 = new ImageView (this);
tv3.setGravity(Gravity.CENTER);
tv3.setImageresorce(R.drawable.image3);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ll.setGravity(Gravity.CENTER);
ll.addView(tv1);
ll.addView(tv2);
ll.addView(tv3);
setContentView(ll);
}
この有用なデータを参照してください
http://mobile.tutsplus.com/tutorials/android/android-layout/
このhttp://developer.android.com/guide/components/fragments.htmlにフラグメントを使用できます
FragmentManager fragmentManager = getFragmentManager()
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
ExampleFragment imageFragment = new ExampleFragment();
fragmentTransaction.add(R.id.image_container, imageFragment);
fragmentTransaction.commit();