I have the population using that Srlkrarr adapter is a ListView. The line layout is given below:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" android: layout_height = "wrap_content" & gt; & Lt; TextView android: id = "@ + id / line" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" android: padding = "10dp" / & gt; & Lt; imageView android: id = "@ + id / enable_image" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignParentRight = "true" Android: layout_alignParentTop = "true" android: padding = "L0dp" Android: ContentDescription = "@ String / image_description" Android: src = "@ Android: Drauble / Checkbox_off_baband" / & gt; & Lt; / RelativeLayout & gt; What I want to do is change the source of sharing the image based on some shared priority, when the activity is created. This code is what I use and it does not work:
shared reference prefs = PreferenceManager.getDefaultSharedPreferences (this); Long-term application profiles ID = prefs.getLong ("applicable profiling ID", -1); if (! appliedProfileId = -1) {/ * See rowView = (View) getListView () getAdapter () getView (info.psition, null, null) .. TextView textView = (text view) rowView.findViewById (R.id.row); * / ListView listView = getListView (); ListAdapter adapter = listView.getAdapter (); See applied rollette = (see) adapter.getView (getItemPositionByAdapterId (adapter, applied profiles id, blank, blank); TextView textView = (TextView) applied RowLayout.findViewById (R.id.row); Log D. ("Asdasd", textView.getText (). ToString ()); ImageView imageView = (ImageView) Apply RowLayout. FindViewById (R.id.enable_image); ImageView.setImageResource (android.R.drawable.checkbox_on_background); SetListAdapter (adapter); } It getItemPositionByAdapterId method:
personal integer getItemPositionByAdapterId (ListAdapter adapter last long id) {(int i = 0; i & LT; Adapter .getCount (); i ++) {if (adapter.getItemId (i) == ID) I come back; } Return -1; } I am able to read the contents of the listview, but can not change them .. Please help :)
You have to override the getView method for this list view.
You need to do something like this.
Override public view getView (see the status of the interview, view the group origin) {if (position == 0) / / first element in the list {convertView.findViewById (R.id. Image1) .setImageURI (....)} and so on ....
Comments
Post a Comment