解決策1:
viewbinder
:の列インデックスを確認する必要があります。
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (columnIndex == cursor.getColumnIndexOrThrow(**??**)) // 0 , 1 , 2 ??
{
sign = (TextView) view;
SharedPreferences currency = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String currency1 = currency.getString("Currency", "$");
sign.setText(currency1);
return true;
}
return false;
}
列インデックスは、通貨のDBcolumnインデックス/データソースの列のインデックスであることに注意してください。
解決策2:解決策2:
たとえばint[]
、バインドするフィールドのを定義している可能性があります。listview
// and an array of the fields we want to bind those fields to
int[] to = new int[] { R.id.field1, R.id.field2, R.id.Currency };
SimpleCursorAdapter entries = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
...条件付きで、0
バインド/表示したくないフィールドのレイアウトIDの代わりに単純に渡すことができます。
int[] to = new int[] { 0, 0, R.id.Currency };
このように、Currencyフィールドのみがバインドされます。
また、力を近づける理由は、技術的には、contentViewに単一 ではなく、多数あるためです。メインレイアウトレベルからはアクセスできません。これは、単一行のスコープでのみ一意です。text65
アップデート :
解決策3:
id
のビューのを確認してくださいViewBinder
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
int viewId = view.getId();
Log.v("ViewBinder", "columnIndex=" + columnIndex + " viewId = " + viewId);
if(viewId == R.id.text65)
{
sign = (TextView) view;
SharedPreferences currency = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String currency1 = currency.getString("Currency", "$");
sign.setText(currency1);
return true;
}
return false;
}
これを試していただけませんか?
便利なヒント:を使用してLog.v
、デバッグせずにコード内の特定の値を確認できます。
それが役に立てば幸い。