Send and Receive Message not display in listview

  • Replies:1
Nabeel Hafeez
  • Forum posts: 1

Aug 5, 2015, 8:01:22 AM via Website

I develop sms app using smsManager. I send and receive sms successfully but send and receive message not display in listview. I use listview adapter for display message in listview but nothing. Listview custom adapter code below:

public class MyCustomAdapter extends ArrayAdapter<String> {

    public MyCustomAdapter(Context context, int textViewResourceId,
            final String wordslist) {
        super(context, textViewResourceId);

    }

    TextView txt_worditem;

    @SuppressLint("ViewHolder") @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        try {
            LayoutInflater inflater = getLayoutInflater();
            row = inflater.inflate(R.layout.worditem, parent, false);
            txt_worditem = (TextView) row
                    .findViewById(R.id.main_txt_worditem);
            //txt_worditem.setText(wordslist.get(position));
                            // txt_worditem.setBackgroundColor(55 + AppSettings.bck_color);
        } catch (Exception e) {
            Toast.makeText(Main.this, e.toString(), Toast.LENGTH_LONG)
            .show();
        }

        return row;
    }
}

Custom adapter set in on Create method:

MyCustomAdapter mdp = new MyCustomAdapter(getApplicationContext(),R.layout.worditem, wordslist); 
lv.setAdapter(mdp); 
lv.setVisibility(View.VISIBLE);

Everything fine in code no error occurred but send and receive message not display in listview. Please help me for displaying message in listview

Reply
Ashish Tripathi
  • Forum posts: 211

Sep 15, 2015, 8:00:45 AM via Website

did you check the wordslist size ???? also your layout.

try for once to check whether code is working or not.

MyCustomAdapter mdp = new MyCustomAdapter(getApplicationContext(),android.R.layout.simple_list_item, wordslist);

before check if wordlist.size()>0 than set adapter else Toast for no messages are avaliable.

Reply