私は動的に取り込まなければならないので、リストビューを使用しています。そのようなよくある質問、項目は質問を表示し、特定の項目を展開してテキストビューを表示する項目をクリックするとListViewアイテム内にTextViewが1つしかないので、ExpandableListViewを使用することはできません。アイテム内の単一のTextViewでListViewを拡張する方法
Item 1 v
----------------------
Item 2 ^
This is also a dynamic text but can be put in a single textview.
----------------------
Item 3 v
----------------------
助けてください:
Item 1 v
----------------------
Item 2 v
----------------------
Item 3 v
したがって、ユーザーは、アイテム2がクリックしたとき!
これは私がこれまでに得たものです!
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = inflater.inflate(R.layout.layout_faq_item, parent, false);
}
FAQObject faq = faqList.get(position);
convertView.setTag(faq);
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FAQObject faq = (FAQObject) view.getTag();
if(faq.isExpanded()) {
view.findViewById(R.id.text_faq_answer_title).setVisibility(View.GONE);
view.findViewById(R.id.text_faq_answer_content).setVisibility(View.GONE);
((TextView)view.findViewById(R.id.text_faq_question)).setCompoundDrawablesWithIntrinsicBounds(0,0,
android.R.drawable.arrow_down_float, 0);
faq.setExpanded(false);
}else{
((TextView)view.findViewById(R.id.text_faq_question)).setText(faq.getQuestion());
((TextView)view.findViewById(R.id.text_faq_answer_content)).setText(faq.getAnswer());
view.findViewById(R.id.text_faq_answer_title).setVisibility(View.VISIBLE);
view.findViewById(R.id.text_faq_answer_content).setVisibility(View.VISIBLE);
((TextView)view.findViewById(R.id.text_faq_question)).setCompoundDrawablesWithIntrinsicBounds(0,0,
android.R.drawable.arrow_up_float, 0);
faq.setExpanded(true);
}
}
});
return convertView;
}
リストはテキストの全長に拡大されていません..!
あなたがこれまで持っているコードを表示し、あなたがしようとしているかを示す必要があります。 – Bryan