package com.sabirjan.Ugunux;

import java.util.List;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class EnglishUgunux extends BaseExpandableListAdapter{
	Activity activity;
	 List<String> grouplist;
	 List<List<String>> childlist;
	 public EnglishUgunux(Activity a ,List<String> grouplist,List<List<String>> childlist) {
	  // TODO Auto-generated constructor stub
	  activity=a;
	  this.grouplist=grouplist;
	  this.childlist=childlist;
	 }
	@Override
	public Object getChild(int groupid, int childid) {
		// TODO Auto-generated method stub
		  return childlist.get(groupid).get(childid);
	}
	@Override
	 public long getChildId(int groupid, int childid) {
		  // TODO Auto-generated method stub
		  return childid;
		 }
	@Override
	 public View getChildView(int grouplistid, int childid, boolean ischild, View viewcontent,
			   ViewGroup viewparent) {
			  // TODO Auto-generated method stub
			  String text = childlist.get(grouplistid).get(childid);
			  return getview(text);
			 }
	public TextView getview(String s){
		  AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(  
		                ViewGroup.LayoutParams.FILL_PARENT, 54); 
		  TextView view = new TextView(activity);
		  view.setLayoutParams(layoutParams);
		  view.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
		  view.setPadding(54, 0, 0, 0);  
		  view.setText(s);  
		  return view;
		 }
	@Override
	 public int getChildrenCount(int childid) {
		  // TODO Auto-generated method stub
		  return childlist.get(childid).size();
		 }
	@Override
	 public Object getGroup(int groupid) {
		  // TODO Auto-generated method stub
		  return grouplist.get(groupid);
		 }
	@Override
	 public int getGroupCount() {
		  // TODO Auto-generated method stub
		  return grouplist.size();
		 }
	@Override
	 public long getGroupId(int groupid) {
		  // TODO Auto-generated method stub
		  return groupid;
		 }
	@Override
	 public View getGroupView(int groupid, boolean arg1, View arg2, ViewGroup arg3) {
		  // TODO Auto-generated method stub
		  String text = grouplist.get(groupid);
		  return getview(text);
		 }
	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return true;
	}
	@Override
	 public boolean isChildSelectable(int arg0, int arg1) {
		  // TODO Auto-generated method stub
		  String sdf = childlist.get(arg0).get(arg1).toString();
		  toastshow(sdf);
		  return true;
		 }
		 
		 public void toastshow(String s){
		  Toast toast = Toast.makeText(activity, s,Toast.LENGTH_SHORT);
		  toast.setGravity(Gravity.BOTTOM, 0, 50);
		  toast.show();
		 }
	 

	
}
