Hi guys,
I'm just a newbie in Android world. I tried to add a ListView inside a tab (or actually in activity), and each listview will be displaying another view that contains component such text, image and etc. this components is got to be dynamic, will be set within the source program
listview layout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="80dip"
android:layout_height="?android:attr/listPreferredItemHeight" android:gravity="center">
<ImageView android:id="@+id/img" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<TextView android:id="@+id/name" android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight" android:textSize="18dip"
android:paddingLeft="10dip" android:gravity="center_vertical" />
</LinearLayout>
onListItemClick :
protected void onListItemClick(ListView l, View v, int position, long id) {
try {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
// TODO Auto-generated method stub
LayoutInflater factory = getLayoutInflater();
View detailview = factory.inflate(R.layout.top_detail,null);
ImageView detailimg = (ImageView) detailview.findViewById(R.id.img_detail);
TextView detailtxt = (TextView) detailview.findViewById(R.id.txt_detail);
if (position == SUKIMA) {
detailimg.setImageResource(R.drawable.sukima);
detailtxt.setText(R.string.sukima_detail);
} else if (position == TAJUUJIN) {
detailimg.setImageResource(R.drawable.pu_tajuujin);
detailtxt.setText(R.string.tajuujin_detail);
} else if (position == LOVERS) {
detailimg.setImageResource(R.drawable.pu_lovers);
detailtxt.setText(R.string.lovers_detail);
}
this.flipper.setInAnimation(AnimationSanmon.inFromRightAnimation());
this.flipper.setOutAnimation(AnimationSanmon.outToLeftAnimation());
this.flipper.showNext();
detailimg.setImageDrawable(detailview.getResources().getDrawable(R.drawable.sukima));
detailtxt.setText(R.string.sukima_detail);
} catch (Exception e) {
e.printStackTrace();
}
}
you could see that I'm trying to set image and text using setImageResource and setText, but after I run it, this text and image component didn't updated.
I'll be appreciate to the solution of this problem.
Kind Regards, Aru