私のアプリケーションは、Eclipse の標準のマスター/詳細フロー アクティビティを使用しています。一部の「タスク」のテキストを変更できるかどうか疑問に思っていました。各タスクは左側にあります。
masterData = new ArrayAdapter<MyTasks.taskItem>(getActivity(),
R.layout.simple_list_item_activated_1,
R.id.text1,
MyTasks.ITEMS);
setListAdapter(masterData);
このコードは、タスクをマスター/詳細フローに追加し、R.Layoutの定数を使用します。コードを変更できません。次のコード行を追加しようとしましたが、何も起こりません:
android:textColor="#FF0000"
R.layout.simple_list_item_activated_1:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:textAppearance="?android:attr/textAppearanceListItemSmall" />
また、独自の xml ファイル (commenttextview.xml) を作成してみました。
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/commenttext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:background="?android:attr/activatedBackgroundIndicator"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:textAppearance="?android:attr/textAppearanceListItemSmall" />
しかし、実際には何も機能しません。誰かが私を助けることができますか?
編集:
これを試しましたが、2 つの ArrayList を結合する必要があります。
nc_masterData = new ArrayAdapter<MyTasks.taskItem>(getActivity(),
R.layout.nocommenttextview, R.id.nocommenttext);
c_masterData = new ArrayAdapter<MyTasks.taskItem>(getActivity(),
R.layout.commenttextview, R.id.commenttext);
for (int i = 0; i < MyTasks.ITEMS.size(); i++) {
if (MyTasks.ITEMS.get(i) != null) {
if (MyTasks.customers[(Integer.parseInt(MyTasks.ITEMS.get(i).id))][10].equals("0")) {
nc_masterData.add(MyTasks.ITEMS.get(i));
}else{
c_masterData.add(MyTasks.ITEMS.get(i));
}
}
}
setListAdapter(nc_masterData);