1
확장 가능한 목록보기에서 일하고 있습니다. 내 데이터베이스 값을 기반으로 childview (child_row)의 imageview에 다른 이미지를 표시해야합니다. 이미지를 설정하려고했지만 아무 것도 작동하지 않습니다.확장 가능한 목록보기의 childrow 사용자 정의
이 도움이 필요하십니까 ?? 미리 감사드립니다 ....
ExpandableListActivity.java
public class ExpList extends ExpandableListActivity
{
String parent_node[];
String custom_child[][][][];
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
SimpleExpandableListAdapterWithEmptyGroups expListAdapter =
new SimpleExpandableListAdapterWithEmptyGroups(
this,
createGroupList(),
R.layout.group_row,
new String[] { "colorName" },
new int[] { R.id.groupname },
createChildList2(),
R.layout.child_row,
new String[] { "name", "number", "date", "time"},
new int[] { R.id.name, R.id.number,R.id.date, R.id.time}
);
setListAdapter(expListAdapter);
// I tried all following methods to put different image in imageview, but not working.
LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.child_row, null);
ImageView img_call = (ImageView)layout.findViewById(R.id.img_call_icon);
img_call.setBackgroundResource(R.drawable.skype);
Drawable d = getResources().getDrawable(R.drawable.skype);
img_call.setBackgroundDrawable(d);
img_call.setImageResource(R.drawable.skype);
img_call.setImageDrawable(d);
}
}
child_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_call_type"
android:src="@drawable/incoming_call"
android:layout_width="40px"
android:layout_height="40px"/>
<TextView
android:id="@+id/space"
android:layout_width="10px"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:textSize="14px"
android:layout_width="115px"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/number"
android:textSize="14px"
android:layout_width="115px"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/date"
android:textSize="14px"
android:layout_width="115px"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/time"
android:textSize="14px"
android:layout_width="115px"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- This is imageview in which I need to display diffrent images -->
<ImageView
android:id="@+id/img_call_icon"
android:layout_width="40px"
android:layout_height="40px"
android:clickable="true"
android:onClick="onClickHandler"/>
</LinearLayout>
</LinearLayout>
공공보기 getChildView 수행 트릭, 감사 당신의 대답은 .. –