我正在使用以下代码。我不知道为什么,但是即使我没有修改第二个 viewList,它的外观也消失了。我不知道如何解决它。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
<ListView
android:id="@+id/listView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
onCreate(){
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dual);
lv1 = (ListView) findViewById(R.id.listView1);
lv2 = (ListView) findViewById(R.id.listView2);
lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , adsGenerator()));
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
getItem = arg0.getItemAtPosition(arg2).toString();
lv2.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,adsGenerator2(getItem) ));
}
});
}