Here i m attaching snap of my problem and code for that. it shows me only the content as object but shows groupname perfectly. the snap for this problem is given in as below link just go throught this image
"http://imageupload.org/?d=4DA941521"(snapshot)
=> I want child data of particular groupname but i m getting groupname instead of child data.
code for this
package com.bestdambikers;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class SectionedDemo extends ListActivity {
String strUrl = "http://192.168.5.10/ijoomer_development/index.php?option=com_ijoomer&plg_name=jomsocial&pview=user&ptask=field_list&userid=80&sessionid="+ConstantData.session_id+"&tmpl=component";
DetailBean dBean;
XmlParser parser;
ArrayList<Object> result;
List<DetailBean> list;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.header_main);
//dBean = new DetailBean();
parser = new XmlParser(strUrl, new DetailBean());
result = parser.ParseUrl("data", "group");
int r = result.size();
for(int i=0; i<result.size(); i++)
{
dBean = (DetailBean)result.get(i);
list=Arrays.asList(dBean);
Collections.shuffle(list);
adapter.addSection(dBean.group_name,
new ArrayAdapter<DetailBean>(this,
android.R.layout.simple_list_item_1,
list));
}
setListAdapter(adapter);
}
SectionedAdapter adapter=new SectionedAdapter() {
protected View getHeaderView(String caption, int index,
View convertView,
ViewGroup parent) {
TextView result=(TextView)convertView;
if (convertView==null) {
result=(TextView)getLayoutInflater()
.inflate(R.layout.header,
null);
}
result.setText(caption);
return(result);
}
};
}
DetailBean.java
public class DetailBean
{
public String data = null;
public String code = null;
public String fields = null;
public String group_name = null;
public String field = null;
public String id = null;
public String name = null;
public String value = null;
public String status = null;
public String required = null;
public String type = null;
public DetailBean()
{
this("","","","","","","","","","","");
}
public DetailBean(String data,String code,String fields, String group_name,String field, String id,String name,String value,String status,String required,String type)
{
this.data = data;
this.code = code;
this.fields = fields;
this.group_name = group_name;
this.field = field;
this.id = id;
this.name = name;
this.value = value;
this.status = status;
this.required = required;
this.type = type;
}
}
A simple solution might be to update DetailBean to include overriding the toString method to retrieve whatever String representation you want for the DetailBean objects.
(Ah. I was beaten by 4 minutes and 2 minutes.)
It looks like you are getting a
String
in yourgetHeaderView
method'scaption
parameter that is made by detailBeanInstance.toString().You should override the
toString
method in DetailBean class to return what you want.Such an override would be:
Place the method above inside your DetailBean class, so it would look like:
Your
DetailBean
is missing atoString()
method so that the method from the parent (i.e.Object
) is taken, which just prints the classname + its address.