Color Of Listview Item Is Very Faint
Sorry if i am repeating the question. I am reading SMS/s from inbox and showing them in the listview. I can see the SMS/s in the listview as listview item after execution. Only pro
Solution 1:
You will need to create a custom layout for your ListView items where you set your desired textcolor.
In this way, you do not even need a custom-adapter.
e.g. custom_textview.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:gravity="center"android:layout_height="wrap_content"
><TextViewandroid:id="@+id/tv"android:textColor="@color/white"android:layout_width="fill_parent"android:gravity="center"android:layout_height="fill_parent"/></LinearLayout>
Then, you can use your layout with the ArrayAdapter:
ArrayAdapter<String> adapter = newArrayAdapter<String>(MainActivity.this, R.layout.custom_textview, aa);
lv.setAdapter(adapter);
Solution 2:
Make Custom layout name row_item.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:ignore="HardcodedText,UselessParent" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="40dp"android:orientation="horizontal" ><TextViewandroid:id="@+id/tv"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center|left"android:layout_marginLeft="10dp"android:text="Medium Text"android:textColor="#000000"android:textAppearance="?android:attr/textAppearanceMedium"android:textSize="16sp" /></LinearLayout></LinearLayout>
Make Custom Adapter globally like:
MyAdapter adp;
now initialize it on onCreate() method:
adp = newMyAdapter (YourActivity.this, yourArrayList);
classMyAdapterextendsBaseAdapter {
Context c;
String[] yourarraylist;
LayoutInflater mInflater;
publicCustomAdapter(Context fullImage, String[] yourarraylist) {
// TODO Auto-generated constructor stubthis.c = fullImage;
this.yourarraylist= yourarraylist;
mInflater = LayoutInflater.from(c);
}
@OverridepublicintgetCount() {
// TODO Auto-generated method stubreturn yourarraylist.length;
}
@Overridepublic Object getItem(int position) {
// TODO Auto-generated method stubreturn position;
}
@OverridepubliclonggetItemId(int position) {
// TODO Auto-generated method stubreturn position;
}
@Overridepublic View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stubif (convertView == null) {
convertView = mInflater.inflate(R.layout.row_item, parent,
false);
TextViewtv= (TextView) convertView.findViewById(R.id.tv);
// set text here
}
return convertView;
}
}
Solution 3:
Add this to your activity_view_task.xml:
android:textColor="#000000"
Post a Comment for "Color Of Listview Item Is Very Faint"