用勇气改变可以改变的事情,用胸怀接受不能改变的事情

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/iteye_2994/article/details/81762038

用勇气改变可以改变的事情,用胸怀接受不能改变的事情,用智慧分辨两者的不同。不必要为自己不能改变的事情伤害自己的情绪,要分清,今天你要做什么,将来你想做什么。

 

学习如何学习、学习如何思考、学习如何用不同方法、角度看问题……

 

- 李开复

展开阅读全文

用IF条件语句改变imageview

12-27

引用会从服务器得到son,我想要用的值是categoryid,比较详细的在下边的代码中。rn我怎么才能用从json取得的 categoryid 来用条件改变imageview?rn我的ImageView在ImageAdapter类里边rn我想要用条件语句rnrn rnrn if(catetgoryid == 1)rn imageview.setImageResource(R.drawable.image1)rn elseif (categoryid == 2 rn imageview.setImageResource(R.drawable.image2)rn else rn imageview.setImageResorce(R.drawable.image3)rn rnJSONrn rn rn "count": 54,rn "data": [rn rn "userid": "24",rn "cardid": "114",rn "title": "meeting now!",rn "carddate": "2012-12-26",rn "categoryid": "2",rn "cardimage": "http://xxx.xxx/data/card/thum/9589266f7983dbe72ff8481800f51ef9.jpg",rn "public": "1",rn "user": rn "user_id": "24",rn "firstname": "kong",rn "lastname": "kea",rn "email": "xxx",rn "picture": "http://xxx.xxx/data/profiles/thum/default.png",rn "friend_status": "NOT_FRIEND"rn rn rn ]rnrnMainActivity.这个是用来获取json categoryid的rnrn @Overridern protected Void doInBackground(String... params) rn rn String url = "http://xxx.xxx.xxx/card/all/30/0/?token=57LzEsmBeykLbDCD04wTgK9WWV2XjJY0XBdqVU0HQvjIdu5EtTWOT1IQ1AYNwxt6Q5bG6FG73uvzLQSDGAIezwc8VcopEp0s63uzbdVgLSfts0TLmuVDOgyfn4lX";rn JSONArray data = null;rn rn try rn rn JSONObject jsonObject = new JSONObject(getJSONUrl(url));rn rn MyArrList = new ArrayList>();rn HashMap map;rn data = jsonObject.getJSONArray("data");rn for (int i = 0; i < data.length(); i++) rn JSONObject c = data.getJSONObject(i);rn map = new HashMap();rn rn // Thumbnail Get ImageBitmap To Objectrn map.put("cardimage", (String) c.getString("cardimage"));rn map.put("ImageThumBitmap",(Bitmap) loadBitmap(c.getString("cardimage")));rn rn map.put("categoryid",(String)c.getString("categoryid")); // use it for condition rn rn MyArrList.add(map);rn rn rn catch (JSONException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn return null;rn rn rn rn在这用条件rn rn public class ImageAdapter extends BaseAdapter rn private Context context;rn private ArrayList> MyArr = new ArrayList>();rn rn public ImageAdapter(Context c,ArrayList> myArrList) rn context = c;rn MyArr = myArrList;rn rn rn public int getCount() rn return MyArr.size();rn rn rn public Object getItem(int position) rn return position;rn rn rn public long getItemId(int position) rn return position;rn rn rn public View getView(int position, View convertView, ViewGroup parent) rn ViewHolder viewHolder;rn viewHolder = new ViewHolder();rn rn LayoutInflater inflater = (LayoutInflater) contextrn .getSystemService(Context.LAYOUT_INFLATER_SERVICE);rn rn if (convertView == null) rn convertView = inflater.inflate(R.layout.grid_item, null);rn rn viewHolder.categoryCard = (ImageView) convertView.findViewById(R.id.category_card);rn rn // ====================== use codition here ===============rn viewHolder.categoryCard.setImageResource(R.drawable.card_beauty); rn viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView1);rn rn try rn viewHolder.imageView.setImageBitmap((Bitmap) MyArr.get(position).get("ImageThumBitmap"));rn catch (Exception e) rn viewHolder.imageView.setImageResource(android.R.drawable.ic_menu_report_image);rn rn rn return convertView;rn rn rn rn 问答

没有更多推荐了,返回首页