내가하고 싶은 것은 2 개의 RadioButton이 있고, 그 중 하나를 클릭하면 ListView1이 표시되고, 다른 RadioButton을 클릭하면, 이것이 내가 내 xml 파일에있어 무엇RadioGroup show 2 개의 다른 ListView를 만드는 방법
ListView2을 보여줍니다
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:paddingRight="5dp"
android:text="Free Apps" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paid Apps" />
</RadioGroup>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/radioGroup1" >
</ListView>
을 그리고 이것은 내 된 .java에있는 것입니다 :
private void populateListView() {
// Create list of items
String[] items = {"Test", "Test 2", "Test 3"};
String[] items2 = {"Bla", "Bla bla", "Bla bla bla"};
// Build Adapter
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.mainitem, items);
ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this, R.layout.mainitem, items2);
// Configure the list view
ListView list = (ListView) findViewById(R.id.listView1);
list.setAdapter(adapter);
}
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(checkedId == R.id.radio0){
// Show items
}
if(checkedId == R.id.radio1){
// Show items2
}
}
public void onClick(View v) {
RadioGroup.clearCheck();
}
당신이 다른 뭔가가 필요, 제발 저에게 알려주세요. 감사!