我的应用程序正在运行,直到我点击我的expandablelist视图中的一个子元素。我不知道为什么因为一切看起来都很好。这是我的主要活动:
expListView = (ExpandableListView) findViewById(R.id.lvExp);
expListView2 = (ExpandableListView) findViewById(R.id.lvExp2);
expListView3 = (ExpandableListView) findViewById(R.id.lvExp3);
expListView4 = (ExpandableListView) findViewById(R.id.lvExp4);
expListView5 = (ExpandableListView) findViewById(R.id.lvExp5);
// preparing list data
prepareListData();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
listAdapter2 = new ExpandableListAdapter(this, listDataHeader2, listDataChild2);
listAdapter3 = new ExpandableListAdapter(this, listDataHeader3, listDataChild3);
listAdapter4 = new ExpandableListAdapter(this, listDataHeader4, listDataChild4);
listAdapter5 = new ExpandableListAdapter(this, listDataHeader5, listDataChild5);
// setting list adapter
expListView.setAdapter(listAdapter);
expListView2.setAdapter(listAdapter3);
expListView3.setAdapter(listAdapter4);
expListView4.setAdapter(listAdapter5);
expListView5.setAdapter(listAdapter2);
expListView5.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (groupPosition == 0) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), internet_sonet_adsl.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(MainActivity.this, internet_sonet_fiber.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(MainActivity.this, internet_sonet_yalin_internet.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(MainActivity.this, internet_sonet_uydu_internet.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(MainActivity.this, internet_tum_paketler.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(MainActivity.this, internet_sonet_fiber_nerede.class);
startActivity(i);
}
if (childPosition == 6) {
Intent i = new Intent(MainActivity.this, internet_hizmet_karsilastirma.class);
startActivity(i);
}
}
if (groupPosition == 1) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), servisler_guvenlik.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(MainActivity.this, servisler_bulut_bilisim.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(MainActivity.this, servisler_internet.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(MainActivity.this, servisler_mobil_servisler.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(MainActivity.this, servisler_sonet_teknoloji.class);
startActivity(i);
}
}
if (groupPosition == 2) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), kampanya_sonet_adsl.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(MainActivity.this, kampanya_sonet_airfiber.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(MainActivity.this, kampanya_sonet_fiber.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(MainActivity.this, kampanya_sonet_yalin_internet.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(MainActivity.this, kampanya_sonet_uydu_internet.class);
startActivity(i);
}
}
if (groupPosition == 3) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), senindunyan_guvenli_evim.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(MainActivity.this, senindunyan_guvenli_isim.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(MainActivity.this, senindunyan_akilli_evim.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(MainActivity.this, senindunyan_akilli_isim.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(MainActivity.this, senindunyan_tum_paketler.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(MainActivity.this, senindunyan_sonet_akilli_tv.class);
startActivity(i);
}
if (childPosition == 6) {
Intent i = new Intent(MainActivity.this, senindunyan_sikca_sorulan_sorular.class);
startActivity(i);
}
}
if (groupPosition == 5) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), cihazlar_sikca_sorulan_sorular.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(MainActivity.this, cihazlar_sonet_musterilerine_ozel.class);
startActivity(i);
}
}
if (groupPosition == 6) {
if (childPosition == 0) {
Intent i = new Intent(getApplicationContext(), destek_fatura_islemleri.class);
startActivity(i);
}
if (childPosition == 1) {
Intent i = new Intent(MainActivity.this, destek_satis_noktalari.class);
startActivity(i);
}
if (childPosition == 2) {
Intent i = new Intent(MainActivity.this, destek_bize_ulasin.class);
startActivity(i);
}
if (childPosition == 3) {
Intent i = new Intent(MainActivity.this, destek_televizyon.class);
startActivity(i);
}
if (childPosition == 4) {
Intent i = new Intent(MainActivity.this, destek_iletisim.class);
startActivity(i);
}
if (childPosition == 5) {
Intent i = new Intent(MainActivity.this, destek_sosyal_medya_sonet.class);
startActivity(i);
}
if (childPosition == 6) {
Intent i = new Intent(MainActivity.this, destek_bolge_cozum_ortakligi.class);
startActivity(i);
}
}
return false;
}
});
}
private void prepareListData() {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
listDataHeader2 = new ArrayList<String>();
listDataChild2 = new HashMap<String, List<String>>();
listDataHeader3 = new ArrayList<String>();
listDataChild3 = new HashMap<String, List<String>>();
listDataHeader4 = new ArrayList<String>();
listDataChild4 = new HashMap<String, List<String>>();
listDataHeader5 = new ArrayList<String>();
listDataChild5 = new HashMap<String, List<String>>();
// Adding child data
listDataHeader.add("Internet");
listDataHeader2.add("Internet");
listDataHeader2.add("Servisler");
listDataHeader2.add("Kampanya");
listDataHeader2.add("Senin Dünyan");
listDataHeader2.add("TV");
listDataHeader2.add("Cihazlar");
listDataHeader2.add("Destek");
listDataHeader3.add("Cihazlar");
listDataHeader4.add("Servisler");
listDataHeader5.add("Diğer");
// Adding child data
List<String> internett = new ArrayList<String>();
internett.add("Sonet ADSL");
internett.add("Sonet Fiber");
internett.add("Sonet Yalın İnternet");
internett.add("Sonet Uydu İnternet");
internett.add("Tüm Paketler");
internett.add("Sıkça Sorulan Sorular");
// Adding child data
List<String> servislerr = new ArrayList<String>();
servislerr.add("Güvenlik");
servislerr.add("Bulut Bilişim");
servislerr.add("İnternet");
servislerr.add("Mobil Servisler");
servislerr.add("Sonet Teknoloji");
List<String> cihazlarr = new ArrayList<String>();
cihazlarr.add("Sıkça Sorulan Sorular");
cihazlarr.add("Sonet Müşterilerine Özel");
List<String> diğer = new ArrayList<String>();
diğer.add("Senin Dünyan");
diğer.add("Sonetlilere Özel");
diğer.add("Destek");
List<String> internet = new ArrayList<String>();
internet.add("Sonet ADSL");
internet.add("Sonet FIBER");
internet.add("Sonet Yalın Internet");
internet.add("Sonet Uydu Internet");
internet.add("Tüm Paketler");
internet.add("Sonet Fiber Nerede?");
internet.add("Hizmet Karşılaştırma");
List<String> servisler = new ArrayList<String>();
servisler.add("Güvenlik");
servisler.add("Bulut Bilişim");
servisler.add("Internet");
servisler.add("Mobil Servisler");
servisler.add("Sonet Teknoloji");
List<String> kampanya = new ArrayList<String>();
kampanya.add("Sonet ADSL");
kampanya.add("Sonet AirFiber");
kampanya.add("Sonet Fiber");
kampanya.add("Sonet Yalın Internet");
kampanya.add("Sonet Uydu Internet");
List<String> senindünyan = new ArrayList<String>();
senindünyan.add("Güvenli Evim");
senindünyan.add("Güvenli İşim");
senindünyan.add("Akıllı Evim");
senindünyan.add("Akıllı İşim");
senindünyan.add("Tüm Paketler");
senindünyan.add("Sonet Akıllı TV");
senindünyan.add("Sıkça Sorulan Sorular");
List<String> tv = new ArrayList<String>();
List<String> cihazlar = new ArrayList<String>();
cihazlar.add("Sıkça Sorulan Sorular");
cihazlar.add("Sonet Müşterilerine Özel");
List<String> destek = new ArrayList<String>();
destek.add("Fatura İşlemleri");
destek.add("Satış Noktaları");
destek.add("Bize Ulaşın");
destek.add("Televizyon");
destek.add("İletişim");
destek.add("Sosyal Medya Sonet");
destek.add("Bölge Çözüm Ortaklığı!");
listDataChild.put(listDataHeader.get(0), internett); // Header, Child data
listDataChild3.put(listDataHeader3.get(0), servislerr); // Header, Child data
listDataChild4.put(listDataHeader4.get(0), cihazlarr); // Header, Child data
listDataChild5.put(listDataHeader5.get(0), diğer); // Header, Child data
listDataChild2.put(listDataHeader2.get(0), internet); // Header, Child data
listDataChild2.put(listDataHeader2.get(1), servisler);
listDataChild2.put(listDataHeader2.get(2), kampanya);
listDataChild2.put(listDataHeader2.get(3), senindünyan);
listDataChild2.put(listDataHeader2.get(4), tv);
listDataChild2.put(listDataHeader2.get(5), cihazlar);
listDataChild2.put(listDataHeader2.get(6), destek);
}
}
这是我的适配器:
public class ExpandableListAdapter extends BaseExpandableListAdapter
{
private Context _context;
private List<String> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<String, List<String>> _listDataChild;
public ExpandableListAdapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listChildData) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.lblListItem);
txtListChild.setText(childText);
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.size();
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
那么我的问题是什么? 我们将不胜感激。