如何创建这样的消耗品/可折叠视图?
冲浪后我不知道,请提出一些实现这个概念的想法
我想要这个:
答案 0 :(得分:0)
我认为你需要ExpandableListView。如果这不起作用,请告诉我。
答案 1 :(得分:0)
public class HelpYou extends ExpandableListActivity {
TextView button1;
private static final String NAME = "NAME";
private static final String IS_EVEN = "IS_EVEN";
private ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.help_dialog_YOUNAMEIT);
button1= (TextView) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v){
finish();}});
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
这是&#34;不同观点的开始点&#34;
for (int i = 0; i < 1; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
String order =getString(R.string.order);
curGroupMap.put(NAME, order);
curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");
List<Map<String, String>> children3 = new ArrayList<Map<String, String>>();
{
Map<String, String> curChildMap = new HashMap<String, String>();
children3.add(curChildMap);
// curChildMap.put(NAME, "Child " + j);
String order1 =getString(R.string.order1);
curChildMap.put(IS_EVEN, order1
);
}
childData.add(children3);
}
再次制作另一个视图
此处是您的适配器
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,
groupData,
R.layout.rowsimpleitemlist,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 },
childData,
R.layout.rowsimpleitemlist2,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 }
);
setListAdapter(mAdapter);
}}
此代码几乎完全符合您的要求。我用我的适配器做了一些时髦的东西。您必须进行一些更改才能在Tab 2中添加这些行。