私の目的は、動作するスピナー(カーソルアダプターを介して入力)を交互の背景に変換することです。同様に: -カーソルアダプタを使用してカスタムレイアウトでスピナーを使用するにはどうすればよいですか?
すべてが正常に動作どこ現在、私は、これを持っている: -
これは、カーソルの特殊なアダプタ(すなわち、プレーンドロップダウン付き)内の関連動作するコードです: -
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return LayoutInflater.from(context).inflate(R.layout.activity_aisle_shop_list_selector, parent, false);
}
@Override
public void bindView(View view,Context context, Cursor cursor) {
determineViewBeingProcessed(view,"BindV",-1);
TextView shopname = (TextView) view.findViewById(R.id.aaslstv01);
shopname.setText(cursor.getString(shops_shopname_offset));
}
私はのオーバーライドを追加しようとしました(以下のコード)。私は、行の色を交互にしたいのですが、ドロップダウン・ビューは空白です。しかし、セレクタの外側をクリックすると、データが取り込まれます(したがって、上記のように、私が望むもののスクリーンショットをどのように管理するか)。 Selectionが正しいItemを設定します。
Iレイアウトを膨張させた後return
を削除する場合、ドロップダウンビューが移入されているが、他の行からのデータを有する(但し、選択が正しい項目を選択)
public View getDropDownView(int position, View convertview, ViewGroup parent) {
View v = convertview;
determineViewBeingProcessed(v,"GetDDV",position);
if(v == null) {
v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_aisle_shop_list_entry, parent, false);
return v;
}
Context context = v.getContext();
TextView shopname = (TextView) v.findViewById(R.id.aasletv01);
shopname.setText(getCursor().getString(shops_shopname_offset));
if(position % 2 == 0) {
v.setBackgroundColor(ContextCompat.getColor(context,R.color.colorlistviewroweven));
} else {
v.setBackgroundColor(ContextCompat.getColor(context,R.color.colorlistviewrowodd));
}
return v;
}