내 xml 파일 :안드로이드 - 왜 ListView 내부의 ListView가 작동하지 않습니까?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/address" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:layout_below="@+id/address"
android:id="@+id/win_title" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/win_list"
android:layout_below="@+id/win_title"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/lose_title" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lose_list"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/cannot_compare_title" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cannot_compare_list"
android:layout_weight="1" />
</LinearLayout>
그리고 이것은 내 사용자 지정 어댑터입니다 :
public class AnalysisResultAdapter extends ArrayAdapter<ComparisonResult> {
static class ViewHolder {
TextView address;
TextView win_title;
ListView win_list;
TextView lose_title;
ListView lose_list;
TextView cannot_compare_title;
ListView cannot_compare_list;
}
private Hashtable<String, SevenEleven[]> sevenElevenData;
public AnalysisResultAdapter(Context context, int resource, List<ComparisonResult> houses) {
super(context, resource, houses);
}
public void setSevenElevenData(Hashtable<String, SevenEleven[]> sevenElevenData) {
this.sevenElevenData = sevenElevenData;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder holder;
if (view == null) {
LayoutInflater viewInflater;
viewInflater = LayoutInflater.from(getContext());
view = viewInflater.inflate(R.layout.analysis_result_list_item, null);
holder = new ViewHolder();
holder.address = (TextView) view.findViewById(R.id.address);
holder.win_title = (TextView) view.findViewById(R.id.win_title);
holder.win_list = (ListView) view.findViewById(R.id.win_list);
holder.lose_title = (TextView) view.findViewById(R.id.lose_title);
holder.lose_list = (ListView) view.findViewById(R.id.lose_list);
holder.cannot_compare_title = (TextView) view.findViewById(R.id.cannot_compare_title);
holder.cannot_compare_list = (ListView) view.findViewById(R.id.cannot_compare_list);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
if (this.sevenElevenData.size() == 0) {
return view;
}
ComparisonResult result = getItem(position);
holder.address.setText(result.house.Address);
if (result.win.size() > 0) {
ArrayList<String> storeNames = new ArrayList<String>();
for (int storeIndex : result.win) {
storeNames.add(this.sevenElevenData.get(result.house.Area)[storeIndex].StoreName);
}
holder.win_title.setText("win");
holder.win_list.setAdapter(new ArrayAdapter<String>(
getContext(),
R.layout.text_list,
R.id.text_list,
storeNames
));
}
if (result.lose.size() > 0) {
ArrayList<String> storeNames = new ArrayList<String>();
for (int storeIndex : result.lose) {
storeNames.add(this.sevenElevenData.get(result.house.Area)[storeIndex].StoreName);
}
holder.lose_title.setText("lose");
holder.lose_list.setAdapter(new ArrayAdapter<String>(
getContext(),
R.layout.text_list,
R.id.text_list,
storeNames
));
}
if (result.cannotBeCompared.size() > 0) {
ArrayList<String> storeNames = new ArrayList<String>();
for (int storeIndex : result.cannotBeCompared) {
storeNames.add(this.sevenElevenData.get(result.house.Area)[storeIndex].StoreName);
}
holder.cannot_compare_title.setText("cannotBeCompared");
holder.cannot_compare_list.setAdapter(new ArrayAdapter<String>(
getContext(),
R.layout.text_list,
R.id.text_list,
storeNames
));
}
return view;
}
}
문제는 다음과 같습니다 만 @ + ID는/주소 텍스트 뷰 텍스트가 성공적으로 다른 상황이 표시되지 않습니다 보여줍니다. 그러나 나는 왜 이것이 일어 났는지 모른다.
이 문제를 어떻게 해결할 수 있습니까? 누군가 나를 도울 수 있습니까?
감사합니다.
'ListView '가 스크롤 가능보기에서 높이를 가져올 수 없기 때문에. 중첩 된 ListView의 높이를 설정해야합니다 –
콘텐츠 길이에 따라 높이를 설정하는 방법은 무엇입니까? – user3087000
수 없습니다. 내 제안 : 중첩 된 Listview 대신 RecyclerView 사용 –