How to display clicked listview item in another activity
<p>I have a challenge with setOnItemClickListener method to display appropriate listItem in another activity. I do this with a Firebase. I have 3  variables(String): Name,Phone,Email</p>

<p>Snippet of my code in <strong>MainActivity:</strong></p>

<pre><code>listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                ChatMessage selectedList = adapter.getItem(position);
                if(selectedList != null) {

                    Intent intent = new Intent(MainActivity.this, MainDetails.class);
                    long listId = adapter.getItemId(position);
                    intent.putExtra(Constants.KEY_LIST_ID, listId);
                    startActivity(intent);
                }
            }
        });
</code></pre>

<p><strong>KEY_LIST_ID</strong> in Constants.class:</p>

<pre><code>public static final String KEY_LIST_ID = "LIST_ID";
</code></pre>

<p>This KEY_LIST_ID is needed to save each itemId?</p>

<p><strong>ChatAdapter:</strong></p>

<pre><code>public class ChatAdapter extends ArrayAdapter&lt;ChatMessage&gt; {

    public ChatAdapter(Context context, int resource) {
        super(context, resource);

    }

    @Override
    public ChatMessage getItem(int position) {
        return super.getItem(getCount() - 1 - position);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;


        if(convertView==null){
            LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
            convertView = inflater.inflate(R.layout.list_item, parent, false);

            viewHolder = new ViewHolder();
            viewHolder.username = (TextView) convertView.findViewById(R.id.list_item_username);
            viewHolder.message = (TextView) convertView.findViewById(R.id.list_item_message);
            viewHolder.email = (TextView) convertView.findViewById(R.id.list_item_email);

            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }

        ChatMessage item = getItem(position);
        if(item != null) {
            viewHolder.username.setText(item.getName());
            viewHolder.message.setText(item.getPhone());
            viewHolder.email.setText(item.getEmail());
        }

        return convertView;
    }




    private static class ViewHolder{
        TextView username;
        TextView message;
        TextView email;
    }
}
</code></pre>

<p><strong>MainDetails:</strong> Activity which should display appropriate listItem:</p>

<pre><code>private TextView detailsName, detailsPhone, detailsEmail;
    private ChatMessage chatMessage;
    private ListView listView;
    private ChatAdapter chatAdapter;
    private String listId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_details);

        detailsName = (TextView) findViewById(R.id.detsName);
        detailsPhone = (TextView) findViewById(R.id.detsText);
        detailsEmail = (TextView) findViewById(R.id.detsEmail);

        Intent intent = this.getIntent();
        listId = intent.getStringExtra(Constants.KEY_LIST_ID);



    }
</code></pre>

<p>Now, it shows nothing in MainDetails.</p>

<p>Could somebody help me how to display every each ListItem in this Activity? </p>