Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid listactivity, baseadapter - imageView
    primarykey
    data
    text
    <p>I have a <code>ListActivity</code>, where I need to show a image and text in every row.</p> <p>The <code>event.xml</code> layout looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;ImageView android:layout_height="wrap_content" android:layout_width="30px" android:layout_marginTop="2px" android:layout_marginRight="2px" android:layout_marginLeft="2px" android:id="@+id/logoImage"&gt; &lt;/ImageView&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/title" android:textSize="15px"&gt;&lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>The activity looks like this:</p> <pre><code> public class Activity extends ListActivity{ public void onCreate(Bundle icicle) { super.onCreate(icicle); dba=new DatabaseAdapter(this); dba.open(); View header = getLayoutInflater().inflate(R.layout.header, null); ListView lv = getListView(); lv.addHeaderView(header); fillOnStart(); } private void fillOnStart(){ ArrayList&lt;Title&gt; temp = dba.returnTitle(); // this works ArrAdapter notes = new ArrAdapter(this, temp); Toast.makeText(this, "Size: " +notes.getCount(), Toast.LENGTH_LONG).show(); //because this show good size setListAdapter(notes); } </code></pre> <p>and my adapter looks like this:</p> <pre><code> private class ArrAdapter extends BaseAdapter{ private Context mContext; private ArrayList&lt;Title&gt; lista; public ArrAdapter(Context c, ArrayList&lt;Title&gt; list){ mContext = c; this.lista =list; } public int getCount() { // TODO Auto-generated method stub return lista.size(); } public Object getItem(int position) { // TODO Auto-generated method stub return position; } public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // ViewHolder vh =null; Title title= lista.get(position); LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.event, parent, false); ImageView imlogo = (ImageView)v.findViewById(R.id.logoImage); TextView textTitle = (TextView)v.findViewById(R.id.title); imlogo.setImageResource(title.getLogo()); textTitle.setText(title.getTit()); return v; } } </code></pre> <p>class title looks like: </p> <pre><code> public class Title { public int id; public String tit; public Bitmap logo; public Bitmap getLogo() { return logo; } ... and other setter and getter } </code></pre> <p>and method returns Arraylist (in dba) with Title look like that: </p> <pre><code> public ArrayList&lt;Title&gt; returnTitle(){ Title t = new Title(1,"aaaaaaaaaa", BitmapFactory.decodeFile("C:\\Users\\hormon\\Desktop\\favicon.ico")); Title t1 = new Title(2,"assdsdsdsdaa", BitmapFactory.decodeFile("C:\\Users\\hormon\\Desktop\\icon.ico")); ArrayList&lt;Title&gt; art = new ArrayList&lt;Title&gt;(2); art.add(t); art.add(t1); return art; } </code></pre> <p>My List activity shows me only text. What I must change to see a image with text?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload