public class ListDetails extends ListActivity
{
ImageButton imagebutton;
LoanDetails details;
ArrayList<String> CreateReqID1, OpenTime1, RequestSummary1, RequestStatus1;
TextView CreateReqID, OpenTime, RequestSummary, RequestStatus;
ListView list;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.listdetails);
CreateReqID1 = (ArrayList<String>) getIntent().getExtras().get("details1");
OpenTime1 = (ArrayList<String>) getIntent().getExtras().get("details2");
RequestSummary1 = (ArrayList<String>) getIntent().getExtras().get("details3");
RequestStatus1 = (ArrayList<String>) getIntent().getExtras().get("details4");
setListAdapter(new MyAdapter(this, R.layout.requestlistview));
}
private class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, int resource) {
super(context, resource);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View row = inflater.inflate(R.layout.requestlistview, parent, false);
Log.i("values set", "success");
CreateReqID = (TextView) row.findViewById(R.id.createReq);
OpenTime = (TextView) row.findViewById(R.id.openTime);
RequestSummary = (TextView) row.findViewById(R.id.requestSumary);
RequestStatus = (TextView) row.findViewById(R.id.status);
CreateReqID.setText(CreateReqID1.get(position));
OpenTime.setText(OpenTime1.get(position));
RequestSummary.setText(RequestSummary1.get(position));
RequestStatus.setText(RequestStatus1.get(position));
return row;
}
}
}
我有上面的代码可以将数据添加到列表视图中,但是我的 getview 方法没有被调用,请告诉我原因。
我的 listview xml 如下所示
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView2"
android:layout_alignRight="@+id/imageButton5"
android:layout_below="@+id/textView1" >
我的列表布局格式如下所示
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFFFF" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView2"
android:layout_marginTop="12dp"
android:layout_x="10dp"
android:layout_y="60dp"
android:text="RequestSummary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textColorLink="#000000" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView4"
android:layout_marginTop="11dp"
android:layout_x="10dp"
android:layout_y="85dp"
android:text="RequestStatus"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textColorHint="#000000" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="11dp"
android:layout_x="10dp"
android:layout_y="35dp"
android:text="OpenTime"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_x="10dp"
android:layout_y="10dp"
android:text="CreateReqID"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:id="@+id/createReq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_marginLeft="29dp"
android:layout_toRightOf="@+id/textView4"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textColorHint="#000000" />
<TextView
android:id="@+id/requestSumary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignLeft="@+id/createReq"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/requestSumary"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
<TextView
android:id="@+id/openTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignLeft="@+id/createReq"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000" />
</RelativeLayout>
我想动态填充文本视图,我得到了数组列表中的所有内容,但我的 getView 方法没有被调用。