[android-developers] Re: Searching on the results JSON listctivity

2012-08-06 Thread Ricardo Cardoso
?

2012/8/5 Ricardo Cardoso rick@gmail.com

 I have a ListActivity and she is populated with the result of a Json ...
 I put a EditText to do a search on ListActivity ... however I do not know
 how to do when the result is a json ... can anyone help me?

 /**

  * Definition of the list adapter

  */

 public class FriendListAdapter extends BaseAdapter {

 private LayoutInflater mInflater;

 EscolhaAmigosFacebook friendsList;


 public FriendListAdapter(EscolhaAmigosFacebook friendsList) {

 this.friendsList = friendsList;

 if (Utility.model == null) {

 Utility.model = new FriendsGetProfilePics();

 }

 Utility.model.setListener(this);

 mInflater = LayoutInflater.from(friendsList.getBaseContext());

 }


 @Override

 public int getCount() {

 return jsonArray.length();

 }


 @Override

 public Object getItem(int position) {

 return null;

 }


 @Override

 public long getItemId(int position) {

 return 0;

 }


 @Override

 public View getView(int position, View convertView, ViewGroup
 parent) {

 JSONObject jsonObject = null;

 try {

 jsonObject = jsonArray.getJSONObject(position);

 } catch (JSONException e1) {

 // TODO Auto-generated catch block

 e1.printStackTrace();

 }





 etSearch.addTextChangedListener(new TextWatcher() {



  @Override

  public void onTextChanged(CharSequence s, int start, int before, 
 intcount) {



  }



  @Override

  public void beforeTextChanged(CharSequence s, int start, int count,

   int after) {





  }



  @Override

  public void afterTextChanged(Editable s) {

   // TODO Auto-generated method stub



  }

  });



 View hView = convertView;

 if (convertView == null) {

 hView = mInflater.inflate(R.layout.friend_item, null);

 ViewHolder holder = new ViewHolder();

 holder.profile_pic = (ImageView) hView.findViewById(R.id.
 profile_pic);

 holder.name = (TextView) hView.findViewById(R.id.name);

 holder.info = (TextView) hView.findViewById(R.id.info);

 hView.setTag(holder);

 }








 ViewHolder holder = (ViewHolder) hView.getTag();

 try {

 holder.profile_pic.setImageBitmap(Utility.model
 .getImage(

 jsonObject.getString(id),
 jsonObject.getString(picture)));

 } catch (JSONException e) {

 holder.name.setText();

 }

 try {

 holder.name.setText(jsonObject.getString(name));

 } catch (JSONException e) {

 holder.name.setText();

 }

 try {

 holder.info.setText(jsonObject.getJSONObject(
 location).getString(name));

 } catch (JSONException e) {

 holder.info.setText();

 }

 return hView;

 }


 }


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Searching on the results JSON listctivity

2012-08-06 Thread Justin Anderson
I don't think anyone really understands your question...

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Mon, Aug 6, 2012 at 6:20 AM, Ricardo Cardoso rick@gmail.com wrote:

 ?


 2012/8/5 Ricardo Cardoso rick@gmail.com

 I have a ListActivity and she is populated with the result of a Json ...
 I put a EditText to do a search on ListActivity ... however I do not know
 how to do when the result is a json ... can anyone help me?

 /**

  * Definition of the list adapter

  */

 public class FriendListAdapter extends BaseAdapter {

 private LayoutInflater mInflater;

 EscolhaAmigosFacebook friendsList;


 public FriendListAdapter(EscolhaAmigosFacebook friendsList) {

 this.friendsList = friendsList;

 if (Utility.model == null) {

 Utility.model = new FriendsGetProfilePics();

 }

 Utility.model.setListener(this);

 mInflater =
 LayoutInflater.from(friendsList.getBaseContext());

 }


 @Override

 public int getCount() {

 return jsonArray.length();

 }


 @Override

 public Object getItem(int position) {

 return null;

 }


 @Override

 public long getItemId(int position) {

 return 0;

 }


 @Override

 public View getView(int position, View convertView, ViewGroup
 parent) {

 JSONObject jsonObject = null;

 try {

 jsonObject = jsonArray.getJSONObject(position);

 } catch (JSONException e1) {

 // TODO Auto-generated catch block

 e1.printStackTrace();

 }





 etSearch.addTextChangedListener(new TextWatcher() {



  @Override

  public void onTextChanged(CharSequence s, int start, int before, 
 intcount) {



  }



  @Override

  public void beforeTextChanged(CharSequence s, int start, int count,

   int after) {





  }



  @Override

  public void afterTextChanged(Editable s) {

   // TODO Auto-generated method stub



  }

  });



 View hView = convertView;

 if (convertView == null) {

 hView = mInflater.inflate(R.layout.friend_item, null);

 ViewHolder holder = new ViewHolder();

 holder.profile_pic = (ImageView) hView.findViewById(R.id.
 profile_pic);

 holder.name = (TextView) hView.findViewById(R.id.name);

 holder.info = (TextView) hView.findViewById(R.id.info);

 hView.setTag(holder);

 }








 ViewHolder holder = (ViewHolder) hView.getTag();

 try {

 holder.profile_pic.setImageBitmap(Utility.model
 .getImage(

 jsonObject.getString(id),
 jsonObject.getString(picture)));

 } catch (JSONException e) {

 holder.name.setText();

 }

 try {

 holder.name.setText(jsonObject.getString(name));

 } catch (JSONException e) {

 holder.name.setText();

 }

 try {

 holder.info.setText(jsonObject.getJSONObject(
 location).getString(name));

 } catch (JSONException e) {

 holder.info.setText();

 }

 return hView;

 }


 }


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en