i have one main activity class in which i define string array which fetch list from XML file saved in res/value which contain list of item . now i want that when any item selected it color change to yellow . how to do this please help :)
thanks in advance ::)
my two file's are list_data.XML and Main Activity.java
List_data.XML
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="tias_list">
<item>About us</item>
<item> Offered</item>
<item> year </item>
<item>Process</item>
<item>item1</item>>
<item>item2</item>>
<item>item3</item>>
<item>item4</item>
</string-array>
</resources>
MY Main Activity class code is
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] tias_list = getResources().getStringArray(R.array.tias_list);
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label,tias_list));
ListView lv = getListView();
lv.setCacheColorHint(0);
lv.setBackgroundResource(R.drawable.black);
lv.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent,View view,int position, long id) {
if (position == 0)
{
Intent myIntent = new Intent(getApplicationContext(), SingleListItem.class);
startActivity(myIntent);
}
else if(position == 1)
{
Intent myIntent = new Intent(getApplicationContext(), lastyear.class);
startActivity(myIntent);
}
else if(position == 2)
{
Intent myIntent = new Intent(getApplicationContext(), la.class);
startActivity(myIntent);
}
else if(position == 3)
{
Intent myIntent = new Intent(getApplicationContext(),la.class);
startActivity(myIntent);
}
else if(position == 4)
{
Intent myIntent = new Intent(getApplicationContext(), SingleListItem.class);
startActivity(myIntent);
}
else if(position == 5)
{
Intent myIntent = new Intent(getApplicationContext(), SingleListItem.class);
startActivity(myIntent);
}
else if(position == 6)
{
Intent myIntent = new Intent(getApplicationContext(), SingleListItem.class);
startActivity(myIntent);
}
else if(position == 7)
{
Intent myIntent = new Intent(getApplicationContext(), SingleListItem.class);
startActivity(myIntent);
}
}
});
}