I got an app that include listview and i want the first line of the listview in blue.
i did the listview from an array xml here is the code&XML:
JAVA:
public class MainActivity extends Activity implements OnItemClickListener {
ListView list;
ArrayAdapter<String> adaptr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list = (ListView) findViewById(R.id.listView1);
adaptr = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1
, getResources().getStringArray(R.array.list_view));
list.setAdapter(adaptr);
list.setOnItemClickListener(this);
list.setFastScrollEnabled(true);
}
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
Dialog dialog1 = new Dialog(this, R.style.PauseDialog);
dialog1.setContentView(R.layout.dialog1);
TextView text = (TextView) dialog1.findViewById(R.id.tv1);
dialog1.setTitle(R.string.Title);
if(position == 1) {
text.setText("First Dialog");
dialog1.show();
}
if(position == 2) {
text.setText("Second Dialog");
dialog1.show();
return;
}
if(position == 3) {
text.setText("Third Dialog");
dialog1.show();
return;
}
}
here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="list_view">
<item>All Rights Saved to XXX</item>
<item>Line 1</item>
<item>Line 2</item>
<item>Line 3</item>
</array>
</resources>
i want the first item(“All Rghits….”) will be in blue(color)
(and the other will be regular(black))
You could programmatically add a HeaderView using listView.addheaderView .
You can change the View color to blue