android中使用json解析的可扩展listview
我对可扩展列表视图有问题。问题是列表仅显示组字段,而不显示子字段。我正在导航抽屉中使用可扩展的listview 这是我的活动课:android中使用json解析的可扩展listview,android,json,expandablelistview,Android,Json,Expandablelistview,我对可扩展列表视图有问题。问题是列表仅显示组字段,而不显示子字段。我正在导航抽屉中使用可扩展的listview 这是我的活动课: public class NewsTabActivity extends Activity { public static String Id, LOGO, WEB_SERV, SUB_CAT, Font; ImageView image; ImageLoader imgloader; String URL_MAIN_CAT, nDr
public class NewsTabActivity extends Activity {
public static String Id, LOGO, WEB_SERV, SUB_CAT, Font;
ImageView image;
ImageLoader imgloader;
String URL_MAIN_CAT, nDrawerSubCat, URL_SUB_CAT, URL_HOME_PAGE;
String[] mainCatName, mainCatId, mainCatId1, subCatParentID;
JSONArray jarray,jarray1;
private DrawerLayout mDrawerLayout;
private ExpandableListView mDrawerList;
private ListView homeListview;
private ActionBarDrawerToggle mDrawerToggle;
// nav drawer title
private CharSequence mDrawerTitle;
// used to store app title
private CharSequence mTitle;
// slide menu items
private String[] navMenuTitles;
ArrayList<NewsList> newsList;
public ArrayList<NewsDrawerItem> navDrawerItems;
public HashMap<NewsDrawerItem, ArrayList<NewsDrawerItem>> navDrawerChildItems;
private NewsDrawerItem newsDrawerItems;
private NewsDrawerListAdapter adapter;
NewsListAdapter adapter1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hometab);
mTitle = mDrawerTitle = getTitle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ExpandableListView) findViewById(R.id.list_slidermenu);
homeListview = (ListView) findViewById(R.id.listView1);
homeListview.setVisibility(View.VISIBLE);
image = (ImageView) findViewById(R.id.imageView1);
imgloader = new ImageLoader(NewsTabActivity.this);
imgloader.DisplayImage(LOGO, image);
nDrawerSubCat = SUB_CAT;
System.out.println("DRAWER_SUBCAT ? = "+nDrawerSubCat);
URL_HOME_PAGE = WEB_SERV + "homenews.php";
URL_MAIN_CAT = WEB_SERV + "maincategory.php";
if(nDrawerSubCat.equalsIgnoreCase("yes")) {
URL_SUB_CAT = WEB_SERV + "subcategory.php";
System.out.println("DRAWER_SUBCAT = "+URL_SUB_CAT);
}
newsList = new ArrayList<NewsList>();
navDrawerItems = new ArrayList<NewsDrawerItem>();
navDrawerChildItems = new HashMap<NewsDrawerItem, ArrayList<NewsDrawerItem>>();
if (WebserviceUtils.isConnectingToInternet(NewsTabActivity.this)) {
new NewsHomePage().execute(URL_HOME_PAGE);
new NewsPaperMainCat().execute(URL_MAIN_CAT);
}
// adding nav drawer items to array
mDrawerList.setOnGroupClickListener(new SlideMenuClickListener());
// setting the nav drawer list adapter
getActionBar().setDisplayHomeAsUpEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, // nav menu toggle icon
R.string.app_name, // nav drawer open - description for
// accessibility
R.string.app_name // nav drawer close - description for
// accessibility
) {
public void onDrawerClosed(View view) {
getActionBar().setTitle("News Live");
// calling onPrepareOptionsMenu() to show action bar icons
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle("News Live");
// calling onPrepareOptionsMenu() to hide action bar icons
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
// on first time display view for first nav item
displayView();
}
}
/**
* Slide menu item click listener
* */
private class SlideMenuClickListener implements
ExpandableListView.OnGroupClickListener,ExpandableListView.OnGroupExpandListener {
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// TODO Auto-generated method stub
displayView();
homeListview.setVisibility(View.GONE);
NewsListActivity.valuesID(navDrawerItems.get(groupPosition).getId());
NewsListActivity.valueWEBSERV(WEB_SERV);
System.out.println("NEWS_LIST_ID = "+navDrawerItems.get(groupPosition).getId());
return false;
}
@Override
public void onGroupExpand(int groupPosition) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
navDrawerItems.get(groupPosition) + " Expanded",
Toast.LENGTH_SHORT).show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// toggle nav drawer on selecting action bar app icon/title
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle action bar actions click
return super.onOptionsItemSelected(item);
}
/* *
* Called when invalidateOptionsMenu() is triggered
*/
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// if nav drawer is opened, hide the action items
return super.onPrepareOptionsMenu(menu);
}
/**
* Diplaying fragment view for selected nav drawer list item
* */
private void displayView() {
// update the main content by replacing fragments
Fragment fragment = null;
fragment = new NewsListActivity();
if (fragment != null) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
// update selected item and title, then close the drawer
mDrawerLayout.closeDrawer(mDrawerList);
} else {
// error in creating fragment
Log.e("NewsTabActivity", "Error in creating fragment");
}
}
private class NewsHomePage extends AsyncTask<String, String, String> {
private ProgressDialog p_dialog;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
p_dialog = ProgressDialog.show(NewsTabActivity.this, "",
"Loading...Please wait...", true);
p_dialog.setCancelable(true);
p_dialog.show();
super.onPreExecute();
}
@Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
JsonParsor json = new JsonParsor();
JSONObject jobject = json.getJSONFromUrl(URL_HOME_PAGE);
try {
JSONArray jarray = jobject.getJSONArray("news");
for (int i = 0; i < jarray.length(); i++) {
JSONObject jobj = jarray.getJSONObject(i);
String id = jobj.getString("Id");
String cid = jobj.getString("c_id");
String title = jobj.getString("title");
String image = jobj.getString("image");
NewsList news = new NewsList();
news.setId(jobj.getString("Id"));
news.setCid(jobj.getString("c_id"));
news.setTitle(jobj.getString("title"));
news.setImage(jobj.getString("image"));
newsList.add(news);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return "sucess";
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
p_dialog.dismiss();
if (result.compareTo("sucess") == 0) {
adapter1 = new NewsListAdapter(NewsTabActivity.this,
R.layout.newslist_single_item, newsList);
homeListview.setAdapter(adapter1);
adapter1.notifyDataSetChanged();
} else {
Toast.makeText(NewsTabActivity.this, "No data Found...",
Toast.LENGTH_LONG).show();
}
}
}
private class NewsPaperMainCat extends AsyncTask<String, String, String> {
private ProgressDialog p_dialog;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
p_dialog = ProgressDialog.show(NewsTabActivity.this, "",
"Loading...Please wait...", true);
p_dialog.setCancelable(true);
p_dialog.show();
super.onPreExecute();
}
@Override
protected String doInBackground(String... arg0) {
// TODO Auto-generated method stub
JsonParsor json = new JsonParsor();
JSONObject jobject,jobject1=null;
int j,i;
ArrayList<NewsDrawerItem> item = new ArrayList<NewsDrawerItem>();
navDrawerItems = new ArrayList<NewsDrawerItem>();
navDrawerChildItems = new HashMap<NewsDrawerItem, ArrayList<NewsDrawerItem>>();
jobject = json.getJSONFromUrl(URL_MAIN_CAT);
if(nDrawerSubCat.equalsIgnoreCase("yes")) {
jobject1 = json.getJSONFromUrl(URL_SUB_CAT);
}
try {
jarray = jobject.getJSONArray("categories");
if(nDrawerSubCat.equalsIgnoreCase("yes")) {
jarray1 = jobject1.getJSONArray("categories");
}
for (i = 0; i < jarray.length(); i++) {
JSONObject jobj = jarray.getJSONObject(i);
mainCatName = new String[jarray.length()];
mainCatId = new String[jarray.length()];
mainCatId[i] = jobj.getString("Id");
mainCatName[i] = jobj.getString("name");
String id = jobj.getString("Id");
String name = jobj.getString("name");
System.out.println("MAIN_ID = " + id + " NAME= " + name);
// adding nav drawer items to array
navDrawerItems.add(new NewsDrawerItem(mainCatName[i], mainCatId[i]));
}
if(nDrawerSubCat.equalsIgnoreCase("yes")) {
for (j = 0; j < jarray1.length(); j++) {
JSONObject jobj = jarray1.getJSONObject(j);
// newsDrawerItems = new NewsDrawerItem();
mainCatName = new String[jarray.length()];
mainCatId1 = new String[jarray.length()];
subCatParentID = new String[jarray.length()];
mainCatId1[j] = jobj.getString("Id");
mainCatName[j] = jobj.getString("name");
subCatParentID[j] = jobj.getString("parent_id");
String id = jobj.getString("Id");
String name = jobj.getString("name");
String pID = jobj.getString("parent_id");
System.out.println("MAIN_SUB_ID = "+id+" NAME= "+name+" PARENT_ID = "+pID);
item = new ArrayList<NewsDrawerItem>();
item.add(new NewsDrawerItem(mainCatName[j], mainCatId1[j]));
}
item = new ArrayList<NewsDrawerItem>();
item.add(new NewsDrawerItem(mainCatName[j], mainCatId1[j]));
navDrawerChildItems.put(navDrawerItems.get(j), item);
}
} catch (Exception e) {
// TODO: handle exception
}
return "sucess";
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
p_dialog.dismiss();
super.onPostExecute(result);
if (result.compareTo("sucess") == 0) {
adapter = new NewsDrawerListAdapter(NewsTabActivity.this,
navDrawerItems, navDrawerChildItems);
mDrawerList.setAdapter(adapter);
adapter.notifyDataSetChanged();
} else
Toast.makeText(NewsTabActivity.this, "No data Found...",
Toast.LENGTH_LONG).show();
}
}
public static void valueID(String id) {
// TODO Auto-generated method stub
Id = id;
}
public static void valueLogo(String logo) {
// TODO Auto-generated method stub
LOGO = logo;
}
public static void valueWebService(String webServ) {
// TODO Auto-generated method stub
WEB_SERV = webServ;
}
public static void valueSubCat(String subCat) {
// TODO Auto-generated method stub
SUB_CAT = subCat;
}
public static void valueFont(String font) {
// TODO Auto-generated method stub
Font = font;
}
}
这是我的适配器类:
public class NewsDrawerListAdapter extends BaseExpandableListAdapter {
Context context;
public ArrayList<NewsDrawerItem> navDrawerItems;
public HashMap<NewsDrawerItem, ArrayList<NewsDrawerItem>> navDrawerChildItems;
public NewsDrawerListAdapter(
Context context,
ArrayList<NewsDrawerItem> navDrawerItems,
HashMap<NewsDrawerItem, ArrayList<NewsDrawerItem>> navDrawerChildItems) {
this.context = context;
this.navDrawerItems = navDrawerItems;
this.navDrawerChildItems = navDrawerChildItems;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
// TODO Auto-generated method stub
return this.navDrawerChildItems.get(
this.navDrawerItems.get(groupPosition)).get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosititon) {
// TODO Auto-generated method stub
return childPosititon;
}
@Override
public View getChildView(int groupPosition, int childPosititon,
boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.drawer_listchild_item,
null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.title_child);
txtListChild.setText("sdv");
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
System.out.println("getChildrenCount_GROUP_POS = "
+ navDrawerItems.get(groupPosition).getChildItem().size());
return navDrawerItems.get(groupPosition).getChildItem().size();
}
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return this.navDrawerItems.get(groupPosition);
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
System.out.println("GROUP_COUNT = " + navDrawerItems.size());
return this.navDrawerItems.size();
}
@Override
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater
.inflate(R.layout.drawer_list_item, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.title);
lblListHeader.setText(Html.fromHtml(navDrawerItems.get(groupPosition).getTitle()));
return convertView;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isChildSelectable(int arg0, int arg1) {
// TODO Auto-generated method stub
return false;
}
}
这是模型类:
public class NewsDrawerItem {
private String title, Id, PId;
private int icon;
private ArrayList<NewsDrawerItem> childItemList = new ArrayList<NewsDrawerItem>();
public NewsDrawerItem() {
}
public NewsDrawerItem(String title, String Id) {
this.title = title;
this.Id = Id;
}
public NewsDrawerItem(String title, String Id, String PId) {
this.title = title;
this.Id = Id;
this.PId = PId;
}
public String getTitle() {
return this.title;
}
public String getId() {
return this.Id;
}
public String getPId() {
return this.PId;
}
public int getIcon() {
return this.icon;
}
public ArrayList<NewsDrawerItem> getChildItem() {
System.out.println("CHILD_ITEM = "+childItemList);
return childItemList;
}
public void setTitle(String title) {
this.title = title;
}
public void setId(String Id) {
this.Id = Id;
}
public void setPId(String PId) {
this.PId = PId;
}
public void setIcon(int icon) {
this.icon = icon;
}
public void setChildItem(ArrayList<NewsDrawerItem> childItemList) {
this.childItemList = childItemList;
}
}
这是我的工作试试看 这是HomeFragment java类
请提供网址。或者将json文本放在doInBackground中,这样就不必下载它。
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Fragment;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.ExpandableListView.OnGroupCollapseListener;
import android.widget.ExpandableListView.OnGroupExpandListener;
import android.widget.TextView;
import android.widget.Toast;
public class HomeFragment extends Fragment {
private static String url = "http://www.androidbegin.com/tutorial/jsonparsetutorial.txt";
private ProgressDialog mprocessingdialog;
private TextView tv_welcomeuser, tv_recentupdate;
private ExpandableListAdapter expandableListAdapter;
private ExpandableListView exp_leaseoffer;
private List<String> listDataHeader;
private View rootView;
private HashMap<String, List<String>> listDataChild;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.wellcome_page, container, false);
tv_welcomeuser = (TextView) rootView.findViewById(R.id.tv_welcomeuser);
tv_recentupdate = (TextView) rootView
.findViewById(R.id.tv_recentupdate);
exp_leaseoffer = (ExpandableListView) rootView.findViewById(R.id.lvExp);
new DownloadJason().execute();
return rootView;
}
private class DownloadJason extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
mprocessingdialog = new ProgressDialog(getActivity());
mprocessingdialog.setTitle("Please Wait..");
mprocessingdialog.setMessage("Loading");
mprocessingdialog.setIndeterminate(false);
mprocessingdialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// TODO Auto-generated method stub
listDataHeader = new ArrayList<String>();
JSONParser jp = new JSONParser();
String jsonstr = jp.makeServiceCall(url, JSONParser.GET);
Log.d("Json url view", jsonstr);
if (jsonstr != null) {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
try {
JSONObject jobj = new JSONObject(jsonstr);
JSONArray jarray = jobj.getJSONArray("worldpopulation");
for (int hk = 0; hk < jarray.length(); hk++) {
JSONObject d = jarray.getJSONObject(hk);
// Adding Header data
listDataHeader.add(d.getString("country"));
// Adding child data for lease offer
List<String> lease_offer = new ArrayList<String>();
lease_offer.add(d.getString("country") + "'s Rank is : "
+ d.getString("rank"));
lease_offer.add("And Population is "+d.getString("population"));
// Header into Child data
listDataChild.put(listDataHeader.get(hk), lease_offer);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
Toast.makeText(getActivity(),
"Please Check internet Connection", Toast.LENGTH_SHORT)
.show();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
mprocessingdialog.dismiss();
expandableListAdapter = new info.tranetech.adurec.fragments.Expandable_adapter(
getActivity(), listDataHeader, listDataChild);
Log.i("groups", listDataHeader.toString());
Log.i("details", listDataChild.toString());
exp_leaseoffer.setAdapter(expandableListAdapter);
exp_leaseoffer.setOnGroupClickListener(new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// TODO Auto-generated method stub
return false;
}
});
// Listview Group expanded listener
exp_leaseoffer
.setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
// Toast.makeText(getActivity().getApplicationContext(),
// listDataHeader.get(groupPosition) + " Expanded",
// Toast.LENGTH_SHORT).show();
}
});
exp_leaseoffer
.setOnGroupCollapseListener(new OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
Toast.makeText(
getActivity().getApplicationContext(),
listDataHeader.get(groupPosition)
+ " Collapsed", Toast.LENGTH_SHORT)
.show();
}
});
exp_leaseoffer.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// Toast.makeText(
// getActivity().getApplicationContext(),
// listDataHeader.get(groupPosition)
// + " : "
// + listDataChild.get(
// listDataHeader.get(groupPosition)).get(
// childPosition), Toast.LENGTH_SHORT)
// .show();
// Intent ilk = new Intent(getActivity(),
// Lease_Offer_one.class);
// startActivity(ilk);
return false;
}
});
}
}
// public Boolean isWifiAvailable() {
//
// try {
// ConnectivityManager connectivityManager = (ConnectivityManager)
// getActivity()
// .getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo wifiInfo = connectivityManager
// .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
//
// if (wifiInfo.isConnected()) {
// return true;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// return false;
// }
// public boolean isNetworkAvailable() {
// ConnectivityManager connectivityManager = (ConnectivityManager)
// getActivity()
// .getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo activeNetworkInfo = connectivityManager
// .getActiveNetworkInfo();
// return activeNetworkInfo != null && activeNetworkInfo.isConnected();
// }
}
**This is Expandable_adapter java class**
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
public class Expandable_adapter extends BaseExpandableListAdapter {
private Context _context;
private List<String> _listDataHeader;
private HashMap<String, List<String>> _listDataChild;
public Expandable_adapter(Context context, List<String> listDataHeader,
HashMap<String, List<String>> listDataChild) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listDataChild;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosition);
}
@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 layoutInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.list_child, null);
}
TextView expandedListTextView = (TextView) convertView
.findViewById(R.id.tv_listchild);
expandedListTextView.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 layoutInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.list_group, null);
}
TextView listTitle = (TextView) convertView
.findViewById(R.id.tv_listtitle);
listTitle.setTypeface(null, Typeface.BOLD);
listTitle.setText(headerTitle);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
**xml wellcome_page**
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/background_welcome" >
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="@drawable/bottom_bar"
android:orientation="horizontal" >
</LinearLayout>
<TextView
android:id="@+id/tv_welcomeuser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="WELCOME USER"
android:textColor="#FFFFFF"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<LinearLayout
android:id="@+id/eeeee"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_below="@+id/tv_welcomeuser"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="@drawable/edit_text"
android:gravity="center" >
<TextView
android:id="@+id/tv_recentupdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:singleLine="true"
android:text="RECENT UPDATES"
android:textColor="#FFFFFF"
android:textSize="18sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<RelativeLayout
android:id="@+id/expl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/header"
android:layout_alignParentLeft="true"
android:layout_below="@+id/eeeee"
android:layout_marginTop="20dp" >
<LinearLayout
android:id="@+id/textLin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="vertical"
android:weightSum="4" >
<TextView
android:id="@+id/tv_adurec"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/lvExp"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:fontFamily="times_roman"
android:text=" Powered by "
android:textColor="#ffffff"
android:textSize="15dp"
tools:ignore="ObsoleteLayoutParam,HardcodedText,SpUsage" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/tv_adurec"
android:layout_centerVertical="true"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:text="ADUREC"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
tools:ignore="ObsoleteLayoutParam,HardcodedText" />
</LinearLayout>
<ExpandableListView
android:id="@+id/lvExp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/textLin"
android:listSelector="@drawable/buttons_effacts"
android:divider="@color/list_divider"
android:dividerHeight="0.8dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ExpandableListView>
</RelativeLayout>
</RelativeLayout>
**list_child.xml **
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="@+id/tv_listchild"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:paddingTop="10dp"
android:textSize="16sp"
android:gravity="center"
android:textColor="#7D1023"
android:background="#ffffff"
android:paddingBottom="10dp" />
</LinearLayout>
**list_group.xml**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_listtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/buttons_effacts"
android:padding="15dp"
android:gravity="center"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>