Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom SimpleCursorAdapter
    primarykey
    data
    text
    <p>I am trying to implement a custom SimpleCursorAdapter but the problem is, wen i run my application, the listView does not show anything. Why is that? Here is my code:</p> <pre><code>package com.messageHider; import android.content.Context; import android.database.Cursor; import android.provider.MediaStore; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.Toast; public class myAdapter extends SimpleCursorAdapter { private Context appContext; private int layout; private Cursor mycursor; public myAdapter(Context context, int layout, Cursor c, String[] from,int[] to) { super(context, layout, c, from, to); this.appContext=context; this.layout=layout; this.mycursor=c; } @Override public int getCount() { return 0; } @Override public Object getItem(int arg0) { return null; } @Override public long getItemId(int arg0) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater=(LayoutInflater)appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView=inflater.inflate(layout, null, true); ImageView imageViewVidIcon=(ImageView)convertView.findViewById(R.id.imageViewVidThumb); imageViewVidIcon.setImageResource(R.drawable.videothumb); ImageView imageViewPlayBtn=(ImageView)convertView.findViewById(R.id.imageViewPlaybtn); imageViewPlayBtn.setImageResource(R.drawable.playbtn); TextView textViewTitle=(TextView)convertView.findViewById(R.id.textViewVideoTitle); String title=mycursor.getString(mycursor.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME)); textViewTitle.setText(title); imageViewPlayBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(appContext, "It works", Toast.LENGTH_LONG).show(); } }); return convertView; } } </code></pre>
    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.
 

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