我有一个可扩展的列表视图,我正在尝试通过单击子行开始一个新活动,但它不能与我一起使用
此外,我想动态添加子项和父项,以便能够使用string.xml中的多个字符串更改它们
package com.example.khloud.finaaaaaal_hospital;
import java.util.ArrayList;
import android.app.ExpandableListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.Toast;
public class Third extends ExpandableListActivity implements
OnChildClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ExpandableListView expandbleLis = getExpandableListView();
expandbleLis.setDividerHeight(2);
expandbleLis.setGroupIndicator(null);
expandbleLis.setClickable(true);
setGroupData();
setChildGroupData();
MyExpandableAdapter mNewAdapter = new MyExpandableAdapter(groupItem, childItem);
mNewAdapter.setInflater((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE),
this);
getExpandableListView().setAdapter(mNewAdapter);
expandbleLis.setOnChildClickListener(this);
}
public void setGroupData() {
groupItem.add("htc");
groupItem.add("sony");
}
ArrayList<String> groupItem = new ArrayList<String>();
ArrayList<Object> childItem = new ArrayList<Object>();
public void setChildGroupData() {
ArrayList<String> child = new ArrayList<String>();
child.add("1");
childItem.add(child);
child = new ArrayList<String>();
child.add("1");
child.add("2");
childItem.add(child);
}
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Intent child0Intent = new Intent(Third.this, Final_list.class);
startActivity(child0Intent);
return true;}}