ListView
에서 다른 색상을 사용하는 데 약간의 문제가 있습니다.다른 색상의 Android 목록보기
나는 몇 가지 있지만, 아무것도 시도가 작동하는 것 같다
개인 클래스 GameRowAdapter는 ArrayAdapter와 { 의 ArrayList 객체를 확장;
public GameRowAdapter(Context context, int textViewResourceId, ArrayList<RowModel> objects) {
super(context, textViewResourceId, objects);
this.objects = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
RowModelViews model;
if (row == null) {
LayoutInflater inflater = LayoutInflater.from(GamePlayerActivity.this);
row = inflater.inflate(R.layout.game_line_layout, null);
model = new RowModelViews();
model.entry = (TextView) row.findViewById(R.id.gameLineEntry);
model.score = (TextView) row.findViewById(R.id.gameLineEntryScore);
row.setTag(model);
} else {
model = (RowModelViews) row.getTag();
}
if (position == 6 || position == 7) {
row.setBackgroundColor(R.color.black);
} else {
row.setBackgroundColor(R.color.light_transparent);
}
model.entry.setText(objects.get(position).entry);
model.score.setText(objects.get(position).score);
return row;
}
}
static class RowModelViews {
TextView entry;
TextView score;
}
static class RowModel {
String entry;
String score;
public RowModel(String entry, String score) {
this.entry = entry;
this.score = score;
}
}
나에게 말할 수있는 사람은 누구입니까?
감사합니다.
UPDATE 여기
는 inflatet 행
<?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="horizontal">
<TextView android:id="@+id/gameLineEntry"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_marginLeft="20dp"
android:textSize="20dp"
android:gravity="center_vertical"/>
<TextView android:id="@+id/gameLineEntryScore"
android:layout_height="fill_parent"
android:layout_width="65dp"
android:layout_marginRight="20dp"
android:gravity="center"
style="@style/Button"
android:layout_gravity="right"/>
</LinearLayout>
무슨 뜻인지 알 수 있습니다. 그러나이 코드를 사용하면 ListView의 모든 행이 검은 색으로 표시됩니다. – Bastaix
배경색을 배경 위치로 설정 하시겠습니까? = {6,7} else 절에서? 빨간색이라고 말하면 6 & 7을 제외한 모든 배경이 빨간색으로 표시됩니다. –
위치가! = {6,7} 인 경우 기본 색상을 설정합니다. 그러나 당신의 정정과 더불어 모든 선은 검게된다?? – Bastaix