0
How do I display the images in the layout with Simplecursoradapter? My code . 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();
}
and my . 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" />
Specify a little more what you want, I won’t look at your code unless I know what to do and what your problem is.
– Jorge B.
Did you have an error? What happened when you implemented the code up there? Encountered some difficulty?
– Math
i want to display the image from the url (photo), from the bd
– Emerson Barcellos
In Textview textFoto you want the image URL to appear and when you click on it the image will appear
– Jorge B.