0
私はいくつかの画像で問題がありますが、シナリオは、画面が開いたら、私はリストビューで複数の画像を設定していますが、画像の1つが自動的に変更されます。ここアンドロイドで画面を開くとイメージが変わるのを避けるには?
private static final String[] itemname = new String[]{"Invite by Facebook",
"Invite by Whatsapp",
"Invite by Email",
"More options"
};
View header;
private ListView m_listView;
private Integer[] imgid = {
R.drawable.facebook,
R.drawable.whatsapp,
R.drawable.em,
R.drawable.share
};
private Integer[] imgArrow = {
R.drawable.arrow, R.drawable.arrow, R.drawable.arrow, R.drawable.arrow
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.refer_earn);
init();
}
private void init() {
Toolbar m_Toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(m_Toolbar);
//noinspection ConstantConditions,ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
CReferAndEarnAdpater adapter = new CReferAndEarnAdpater(this, itemname, imgid, imgArrow);
m_listView = (ListView) findViewById(R.id.list);
//code to add header and footer to listview
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup) inflater.inflate(R.layout.snippet_item2, m_listView,
false);
m_listView.addHeaderView(header, null, false);
m_listView.setAdapter(adapter);
} アダプタのコードである: -
private Activity context;
private String[] itemname;
private Integer[] imgid;
private Integer[] imgArrow;
public CReferAndEarnAdpater(Activity context, String[] itemname, Integer[] imgid, Integer[] imgArrow) {
super(context, R.layout.refer_item, itemname);
// TODO Auto-generated constructor stub
this.context=context;
this.itemname=itemname;
this.imgid=imgid;
this.imgArrow = imgArrow;
}
public View getView(int position,View view,ViewGroup parent) {
LayoutInflater inflater=context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.refer_item, null, true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.title);
ImageView imageView = (ImageView) rowView.findViewById(R.id.thumbnail);
ImageView arrow = (ImageView) rowView.findViewById(R.id.arrow);
txtTitle.setText(itemname[position]);
imageView.setImageResource(imgid[position]);
arrow.setImageResource(imgArrow[position]);
Animation animation = null;
animation = AnimationUtils.loadAnimation(context,R.anim.push_up_in);
animation.setDuration(1000);
rowView.startAnimation(animation);
return rowView;
};
}
、あなたのスクリーンショット –
をしてくださいポストは、コードを示して? – Konstantin
あなたのコードを投稿してください... –