Hello,i'm new in android development field and in my first project i'm doing a facebook application which loads friends name and birthdates.
Below is the method which returns friends name and birthday..
I want to show the result in a listview.
Below is the code from where i need to access the Arraylist list..
I made all those codes in 2 hours but this problem makes me stop and tired for 2 days! So anyone can give good suggestions me how can i load and print the contents of "list" in ShowList class,that was loaded in class1?Thanks for advance..
Below is the method which returns friends name and birthday..
Code:
//class1.java
public void getDates_method() throws JSONException, MalformedURLException, IOException, FacebookError
{
List<Model> list = new ArrayList<Model>();
//String name="Test";
try
{
Bundle bdle=new Bundle();
bdle.putString("fields","name,birthday");
//facebook.request("me/friends",bdle);
JSONObject json = Util.parseJson(facebook.request("me/friends",bdle));
View tv=findViewById(R.id.textbox_textview);
//EditText tvv=(EditText)tv;
//tvv.setText(" ");
//edt.setText(json.toString());
JSONArray jsonarr=json.getJSONArray("data");
int len=jsonarr.length();
TotalFriend=len;
CharSequence l=String.valueOf(len);
//tvv.append(l+"\n");
String s1,s2;
for(int i=0;i<len;i++)
{
String istring=String.valueOf(i);
JSONObject j=jsonarr.getJSONObject(i);
if(j.toString().contains("birthday"))
{
s1=j.getString("name");
s2=j.getString("birthday");
user_name[i]=s1;
birth_dates[i]=s2;
list.add(get(user_name[i],birth_dates[i]));
}catch(Exception e)
{
showToast(e.getMessage());
}
}
I want to show the result in a listview.
Below is the code from where i need to access the Arraylist list..
Code:
public class ShowList extends ListActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
List<Model> list = new ArrayList<Model>();
ArrayAdapter<Model> adapter = new MyCustomArrayAdapter(this, list);
setListAdapter(adapter);
///////I need to load the Arraylist list here to print in listview ///////
}
private Model get(String s,String place)
{
return new Model(s,place);
}
}
I made all those codes in 2 hours but this problem makes me stop and tired for 2 days! So anyone can give good suggestions me how can i load and print the contents of "list" in ShowList class,that was loaded in class1?Thanks for advance..