Como eu faço para exibir a imagens no layout com SimpleCursorAdapter? Meu código .java:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listarordens);
SQLiteDatabase db = openOrCreateDatabase("ordens.db", Context.MODE_PRIVATE, null);
ListView ltwLocais = (ListView)findViewById(R.id.listHist);
Cursor cursor = db.rawQuery("SELECT * FROM ordens ORDER BY _id ASC",null);
String[] from = {"_id","numero","descricao","datahora","foto"};
int[] to = {R.id.textId, R.id.textNumero, R.id.textDescricao,R.id.textDatahora,R.id.textFoto};
@SuppressWarnings("deprecation")
SimpleCursorAdapter ad = new SimpleCursorAdapter(getBaseContext(), R.layout.model_listar, cursor, from, to);
ltwLocais.setAdapter(ad);
db.close();
}
e meu .xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/textNumero"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textDescricao"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textNumero"
android:layout_marginTop="14dp"
android:layout_weight="0.77"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<TextView
android:id="@+id/textDatahora"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textFoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textDatahora"
android:layout_toLeftOf="@+id/textNumero"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textFoto"
android:layout_below="@+id/textFoto"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />