मेरे आवेदन में मैं सूची दृश्य टेक्स्ट रंग बदलना चाहता हूं। इस मामले में मैं सूची दृश्य के लिए एक्सएमएल फ़ाइल का उपयोग कर रहा हूं। क्या यह संभव है? यदि हां तो उदाहरण दें।सूची बदलें कैसे बदलें टेक्स्ट रंग
आप ArrayAdapter
के बजाय डिफ़ॉल्ट android.R.layout.simple_list_item_single_choice
पास करने का, सभी ListView
वस्तुओं के रंग बदलने के लिए चाहते हैं, तो gender.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/topelg"
>
<ListView
android:id="@+id/android:list"
android:layout_marginTop="60dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#000000"
/>
</LinearLayout>
Egender.java
package com.Elgifto;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
public class Egender extends ListActivity{
Button b1;
ListView lv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gender);
// b1=(Button) findViewById(R.id.butt1);
b1=new Button(this);
b1.setText("Done");
//b1.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
lv=(ListView) findViewById(android.R.id.list);
lv.addHeaderView(b1);
b1.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
// To send a result, simply call setResult() before your
// activity is finished.
finish();
}
});
lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_single_choice, GENDER));
lv.setBackgroundColor(Color.BLACK);
lv.setItemsCanFocus(false);
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lv.setTextFilterEnabled(true);
}
private static final String[] GENDER = new String[] {
"Male","Female"
};
}
सुपर ब्रो !!!!!! – Karthik
नमस्ते मैंने उपरोक्त कोड का उपयोग किया .. लेकिन चयनित आइटम सक्षम नहीं हैं यानी, अनुपात बटन सक्षम नहीं है। उसको कैसे करे – user1835052