Str*_*ing 7 android expandablelistview android-intent android-listview
我已经按照这个示例教程开发了一个示例应用程序http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/

如果我点击Core 我想在Core下的同一个屏幕中加载另一个列表,我怎么能这样做?使用我的下面的代码我可以在另一个屏幕中加载子列表,帮助?
我的ChildClickListener代码在这里:
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
Log.d("onChildClick", "onChildClick");
String position = (String) parentItems.get(groupPosition);
Log.d("position", position);
String child = listDataChild.get(position).get(childPosition);
Log.d("child", child);
if (child.equalsIgnoreCase("Core")) {
ArrayList<String> parentItems = new ArrayList<String>();
HashMap<String, List<String>> listDataChild = new HashMap<String, List<String>>();
ArrayList<String> childItems = new ArrayList<String>();
childItems.add("corejava");
childItems.add("corejava");
childItems.add("corejava");
childItems.add("corejava");
parentItems.add(position);
listDataChild.put(parentItems.get(0), childItems);
expandableList = (ExpandableListView) findViewById(R.id.lvExp);
CoreAdapter adapter = new CoreAdapter(parentItems,
listDataChild);
CustExpListview SecondLevelexplv = new CustExpListview(
MainActivity.this);
adapter.setInflater(
(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE),
MainActivity.this);
SecondLevelexplv.setAdapter(adapter);
SecondLevelexplv.setGroupIndicator(null);
expandableList.setAdapter(adapter);
}
Run Code Online (Sandbox Code Playgroud)
您必须在 xml 文件中创建一个布局(来自您的核心文本视图),并在该 imageView 的 onClick 下方显示一个图像视图,您只需使您的布局消失并可见,我刚刚给了您方向,剩下的依赖于您的技能 :)
<RelativeLayout
android:id="@+id/option"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:gravity="center"
android:orientation="horizontal" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/navigationIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/nn" />
<ImageView
android:id="@+id/callOption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/phonee" />
<ImageView
android:id="@+id/imageViewfeedback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/editer" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在 Jave 文件中
linear.setVisibility(View.GONE);
option.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
if(count==0)
{
linear.setVisibility(View.VISIBLE);
count=1;
}
else
{
linear.setVisibility(View.GONE);
count=0;
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5003 次 |
| 最近记录: |