How To Change Text Color Which Is There In Alert Dialog's Listview?
Following is my code to display a simple Alert Dialog, when a button is clicked, AlertDialog.Builder newImage = new AlertDialog.Builder( MyActivity.this, AlertDialog.THEME_HOLO_LI
Solution 1:
Try this
final ArrayAdapter<String> arrayAdapter = newArrayAdapter<String> ( MyActivity.this, android.R.layout.simple_list_item_1 ) {
@Overridepublic View getView(int position, View convertView, ViewGroup parent) {
Viewview=super.getView(position, convertView, parent);
TextViewtext1= (TextView) view.findViewById(android.R.id.text1);
text1.setTextColor(Color.BLACK);
return view;
}
};
Simply override the getview of the ArrayAdapter
and find the textView to change the color
Solution 2:
TextViewtxt1= (TextView) v.findViewById(android.R.id.text1);
txt1.setTextColor(Color.RED);
UPDATE
final ArrayAdapter<String> arrayAdapter = newArrayAdapter<String> ( MyActivity.this, android.R.layout.simple_list_item_1 ) {
@Overridepublic View getView(int position, View convertView, ViewGroup parent) {
Viewview=super.getView(position, convertView, parent);
TextViewtext1= (TextView) view.findViewById(android.R.id.text1);
text1.setTextColor(Color.RED);
return view;
}
};
I hope this will help you.
Solution 3:
Just use your custom xml file for this instead of android.R.layout.simple_list_item_1
and pass it to ArrayAdapter.
Like this :
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="#ff00ff"android:textSize="20sp"android:text="TextView" /></LinearLayout>
And change adapter:
final ArrayAdapter<String> arrayAdapter = newArrayAdapter<String> (this,R.layout.Your_xml,R.id.textView1);
Solution 4:
you need to define custem alert Dialog view in layout like that first and then perform functionality
LayoutInflaterfactory= LayoutInflater.from(YourCurrentclass.this);
ViewdeleteDialogView= factory.inflate(R.layout.mylayout, null);
finalAlertDialogdeleteDialog=newAlertDialog.Builder(
YourCurrentclass.this).create();
deleteDialog.setView(deleteDialogView);
finalTextViewtext= (TextView) deleteDialogView
.findViewById(R.id.textv2);
Buttonp= (Button) deleteDialogView.findViewById(R.id.plusbtn);
Buttonm= (Button) deleteDialogView.findViewById(R.id.minusbtn);
p.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View v) {
// TODO Auto-generated method stub
text.setTextColor(Color.BLACK);
}
});
also you can change it from layout(mylayout) file when you create custom dilaoag like above in this .
Solution 5:
Use this easiest way to change text color :
Create String value into string.xml file in values folder like below
<string name="text1">Font color is <font fgcolor="#000000">Takefrom camera</font></string>
and you can use this string into adapter by this:
arrayAdapter.add(getResources().getString(R.string.text1));
hope this will work.Good luck..
Post a Comment for "How To Change Text Color Which Is There In Alert Dialog's Listview?"