I am making an application for an Android tablet. In this case, I need to display two lists. One for a simple list and one for a custom list. As soon as I click on a simple list line, then these details should be sent to another user list. For this, I took a fragment to display both lists in one screen. For a custom ListView, I was adapted to a custom adapter to bind custom data. But when I am in a simple list line, the application shows an unresponsive error. My code will be like this. My snippet contains code like this
public class listDetails extends Fragment{ private int nAndroids; public static ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>(); ListDetailsAdapter adapter; static final String KEY_Title = "title";
}
And my custom adapter code like this
public class ListDetailsAdapter extends BaseAdapter{ ///private listDetails listactivity; private Activity activity; private ArrayList<HashMap<String, String>> data; private static LayoutInflater inflater=null; public ListDetailsAdapter(Activity a, ArrayList<HashMap<String, String>> d) { activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { // TODO Auto-generated method stub return data.size(); } public Object getItem(int position) { // TODO Auto-generated method stub return position; } public long getItemId(int position) { // TODO Auto-generated method stub return position; } public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View vi=convertView; if(convertView==null) vi = inflater.inflate(R.layout.customlist, null); TextView title = (TextView)vi.findViewById(R.id.txtTitle); Button btnone = (Button)vi.findViewById(R.id.btnfirst); Button btntwo = (Button)vi.findViewById(R.id.btnsecond); Button btnthree = (Button)vi.findViewById(R.id.btnthird); Button btnfour = (Button)vi.findViewById(R.id.btnfourth); Button btnfive = (Button)vi.findViewById(R.id.btnfifth); btnone.setOnClickListener(oneclick); btntwo.setOnClickListener(twoclick); btnthree.setOnClickListener(thrirdclick); HashMap<String, String> mymap = new HashMap<String, String>(); mymap = data.get(position); title.setText(mymap.get(listDetails.KEY_Title)); return vi; } private View.OnClickListener oneclick = new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Log.e("button clicked", "button one clicked"); } };
}
Please tell me what is going wrong in the above code.
source share