I am using a ListView as shown below in filename browse.xml.
<ListView
android:id="@+id/listView1"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout1" >
</ListView>
And I am filling this listView inside onCreate() method as:
files1=new ArrayList<String>();
File sdcard=Environment.getExternalStorageDirectory();
files1 = getListFiles(new File(sdcard.getAbsolutePath()+File.separatorChar));
ArrayAdapter<String> fileList =new ArrayAdapter<String>(this, R.layout.row,files1);
setListAdapter(fileList);
row.xml is shown below as:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowtext"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:textSize="20dp"
android:textColor="#000000"
android:background="#FFFFFF"/>
This whole program is am showing all the files of sdcard at listView and on click of any listitem, am saving that file name into sharedPrefernce..Now I want to change the text color of file name(List items) in the ListView which are there in SharedPrefernce..
[EDIT]: Here am using ArrayAdapter default constructor to list all the items in a listview
Pls suggest me something..
Thanks..
We can change the textcolor dynamically for list item in the getView() of Adapter.