我正在使用这样的自定义列表视图。如何将子项(收件箱)添加到列表项(来自)?
for (int k = 0; k < fromb.length; ++k) {
if(k==0)
{
frin = fromb[k]+"\n"+inboxb[k];
}
else
{
frin = frin + "##"+fromb[k]+"\n"+inboxb[k];
}
}
frin1=frin.split("##");
lView.setAdapter(new ArrayAdapter<String>(this,R.layout.single_choice, frin1));
//lView.setAdapter(new ArrayAdapter<String>(this,R.layout.single_choice, inboxb));
lView.setTextFilterEnabled(true);
lView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String s1=(String) ((TextView) view).getText();
for (int i=0;i<frin1.length;i++)
{
//Log.i("TextOnly2",bookmarkurlsb[i]);
if(frin1[i]==s1)
{
String fromf=fromb[i];
String inboxf=inboxb[i];
Intent intent = new Intent(Inbox.this,Details.class);
intent.putExtra("from", fromf);
intent.putExtra("inbox", inboxf);
startActivity(intent);
}
else
{
}
}
}
});
布局:R.layout.single_choice
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TextView15"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17sp"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:background="#444444"
android:textColor="@color/list_color"
android:minHeight="?android:attr/listPreferredItemHeight"
/>