解决集合里有多个对象分别赋值给不同控件的问题

    xiaoxiao2026-04-08  3

    eclipse里一个集合含有多个对象,那在studio端赋值的时候经常会忘记了怎么分别赋值,写下笔记防止忘记。 studio端: //新闻列表 List news; List gnews;

    在 onCreateView找到他们的id @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment Log.i(“zjn”,”onCreateView”); View view=inflater.inflate(R.layout.fragment_gamehome, container, false); button= (RadioButton) view.findViewById(R.id.rb_dangji); //新闻栏 news_img= (SimpleDraweeView) view.findViewById(R.id.game_news_img); title= (TextView) view.findViewById(R.id.game_news_title); context= (TextView) view.findViewById(R.id.game_news_context); news_img2= (SimpleDraweeView) view.findViewById(R.id.game_news_img2); title2= (TextView) view.findViewById(R.id.game_news_title2); context2= (TextView) view.findViewById(R.id.game_news_context2); news_img3= (SimpleDraweeView) view.findViewById(R.id.game_news_img3); title3= (TextView) view.findViewById(R.id.game_news_title3); context3= (TextView) view.findViewById(R.id.game_news_context3);

    private void ConnectGame_home() { requestParams.addQueryStringParameter(“flag”,”game_home”); x.http().get(requestParams, new Callback.CommonCallback() { @Override public void onSuccess(String result) { gson=new Gson(); game_home_boject=gson.fromJson(result,Game_home_object.class); //接收新闻列表里的数据 news =game_home_boject.getGame_news(); gnews=new ArrayList();

    news_img.setImageURI(news.get(0).getGame_news_img()); title.setText(news.get(0).getGame_news_title()); context.setText(news.get(0).getGame_news_context()); news_img2.setImageURI(news.get(1).getGame_news_img()); title2.setText(news.get(1).getGame_news_title()); context2.setText(news.get(1).getGame_news_context()); news_img3.setImageURI(news.get(2).getGame_news_img()); title3.setText(news.get(2).getGame_news_title()); context3.setText(news.get(2).getGame_news_context()); }
    转载请注明原文地址: https://ju.6miu.com/read-1308614.html
    最新回复(0)