gpt4 book ai didi

android - 改变文字颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:25:25 26 4
gpt4 key购买 nike

我有一个白色的背景,但是这个布局我被阻止了,因为文本颜色也是白色的,我找不到一个解决方案让它变成红色,所以我可以设置我的白色背景,请帮忙我不得不为她使用红色背景,这样我才能看到白色文字)。

public class QueueListActivity extends ListActivity {
// LIST OF ARRAY STRINGS WHICH WILL SERVE AS LIST ITEMS
ArrayList<String> listItems = new ArrayList<String>();
String newtext;
String listFiles;
// DEFINING STRING ADAPTER WHICH WILL HANDLE DATA OF LISTVIEW
ArrayAdapter<String> adapter;

// RECORDING HOW MUCH TIMES BUTTON WAS CLICKED
int clickCounter = 0;

ArrayList<String> selectedItems = new ArrayList<String>();


@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.queuelistactivity);
Bundle extras1 = getIntent().getExtras();
listFiles=GetFiles();

StringTokenizer tokonizer1 = new StringTokenizer(listFiles,";");
while(tokonizer1.hasMoreElements()){
Log.i("verif","0");
listItems.add(tokonizer1.nextToken());}
initializeListItems();



if (extras1 != null) {
newtext = extras1.getString("newitem");
listItems.add(newtext);
adapter.notifyDataSetChanged();
getListView().setItemChecked(listItems.size() - 1, false);

}




}



// METHOD WHICH WILL HANDLE DYNAMIC INSERTION
public void addItems(View v) {

Intent intent = new Intent(QueueListActivity.this, AjouterFiles.class);
QueueListActivity.this.startActivity(intent);


/*
listItems.add(userName);
adapter.notifyDataSetChanged();
getListView().setItemChecked(listItems.size() - 1, false);*/


}

public void deleteItems(View v) {
String toDelete = "";
SparseBooleanArray sp = getListView().getCheckedItemPositions();

for (int i = 0; i < sp.size(); i++) {
toDelete += ";" + sp.get(i);
if (sp.get(i)) {
listItems.remove(i);
}

}
adapter.notifyDataSetChanged();
Toast.makeText(getApplicationContext(), toDelete, Toast.LENGTH_LONG).show();
initializeListItems();
}

private void initializeListItems() {
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice, listItems);
setListAdapter(adapter);
ListView lv = getListView();
lv.setCacheColorHint(Color.rgb(0, 0, 0));
lv.setBackgroundColor(Color.rgb(178, 34, 34));


for (int i = 0; i < lv.getCount(); i++) {
lv.setItemChecked(i, false);
}
}

最佳答案

最好的技巧是从 android.R.layout.simple_list_item_multiple_choice 复制内容布局文件并制作自己的布局(my_list_view 并编辑 xml 文件并更改文本颜色。

adapter = new ArrayAdapter(this,my_list_view, listItems);

编辑保存此文件为my_list_view;

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:background="#FFFFFF" //white background
android:textColor="#000000" //black color text
/>

关于android - 改变文字颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10633542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com