有人可以告诉我如何在edit
中的单个headerview
的所有子视图下方添加ExpandableListView
按钮,当我点击该编辑子按钮时,所有属于该标题将在下一个活动中移动?
感谢。
ExpandableListAdapter listAdapter;
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
protected void onPostExecute(String result) {
if (dataarray == null || dataarray.length() == 0) {
AlertDialog alertDialog = new AlertDialog.Builder(
ExperienceDetail.this).create();
alertDialog.setTitle("Experience Detail");
String message = "Experience Detail not retrieved";
alertDialog.setMessage(message);
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
});
alertDialog.show();
} else {
try{
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
TextView edit = (TextView) convertView
.findViewById(R.id.cancelbtn); */
List<String> hname = new ArrayList<String>();
for (int i = 0; i < dataarray.length(); i++) {
JSONObject dataobject = new JSONObject();
dataobject = dataarray.getJSONObject(i);
if(dataobject.getString("employer_name")!=null)
{
listDataHeader.add(dataobject.getString("employer_name"));
// Adding child data
hname.add("Employer Name" +" " +" : " +" " +dataobject.getString("employer_name"));
hname.add("Designation" +" "+" : " +" " +dataobject.getString("designation"));
if(dataobject.getString("from_date")!=null)
{
hname.add("From Date" +" "+" : " +" " +dataobject.getString("from_date"));
}
else
hname.add("From Date" +" "+" : " +" " +" ");
if(dataobject.getString("to_date")!=null)
hname.add("To Date" +" "+" : " +" " +dataobject.getString("to_date"));
else
hname.add("To Date" +" "+" : " +" " +" ");
hname.add("Job Location" +" "+" : " +" " +dataobject.getString("job_location"));
hname.add("Edit");
listDataChild.put(listDataHeader.get(i).toString(), hname); // Header, Child dat
listAdapter = new ExpandableListAdapter(ExperienceDetail.this, listDataHeader, listDataChild);
// setting list adapter
expListView.setAdapter(listAdapter);
}catch(Exception e){
e.printStackTrace();
}
答案 0 :(得分:0)
@Override
public int getChildrenCount(int groupPosition)
{
String title= listDataHeader.get(groupPosition);
normal_Child_Count=listDataChild.gett(title).size()
return normal_Child_Count+1;
}
@Override
public View getChildView(int groupPosition, final int childPosition,boolean sLastChild, View convertView, ViewGroup parent)
{
if(childPosition==normal_Child_Count)
{
convertView = inflater.inflate(R.layout.EDIT_LAYOUT, null);//seperate layout for editOption
}
else
{
convertView = inflater.inflate(R.layout.NORMAL_LAYOUT, null);//seperate layout for normal childs
}
if(childPosition==normal_Child_Count)
{
Button b=convertView.findViewById(R.id.BUTTON_ID);
b.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
//copy relevent data to Bundle
//Start an activity by intent with bundle
}
});
}
else
{
//Do normal child item data assigning to view work here
}
return convertView;
}