Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:10:31+00:00 2026-06-16T15:10:31+00:00

I have a FragmentActivity which loads a RelativeLayout with a ListView above an EditText

  • 0

I have a FragmentActivity which loads a RelativeLayout with a ListView above an EditText and a Button. I cannot seem to get the keyboard to show up in any method. When I touch it or set focus to it, nothing happens. When I automatically request focus, nothing happens. How do I get the keyboard to show up? Isn’t this supposed to be automatic? I’d like to simulate GTALK’s chat input.

activity_contact_chat.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal" >

    <Button
        android:id="@+id/details_record_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/chat_message_input"
        android:text="Send" />

   <EditText
       android:id="@+id/chat_message_input"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       android:layout_alignParentLeft="true"
       android:layout_toLeftOf="@+id/details_record_button"
       android:ems="10"
       android:gravity="top|left"
       android:hint="@string/message_hint"
       android:lines="1"
       android:maxLines="10"
       android:paddingRight="10dp"
       android:paddingTop="10dp"
       android:scrollbars="vertical" >

    </EditText>

    <ListView
        android:id="@+id/messages_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/chat_message_input"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="#000000" >

    </ListView>

</RelativeLayout>

ContactChatFragment:

import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class ContactChatFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>{

    ListView messageList;
    Long contact_id;
    String contact_UUID, contact_name;

    private static final int CONTACT_CHAT_LOADER = 0x11;
    MessageListAdapter adapter;

    private static final String STATE_ACTIVATED_POSITION = "activated_position";
    private int mActivatedPosition = ListView.INVALID_POSITION;

    public static final String EXTRA_CONTACTID = "item_id";
    String contact_rowID;
    @Override
    public void onCreate(Bundle savedInstances) {
        super.onCreate(savedInstances);

        if (getArguments().containsKey(EXTRA_CONTACTID)) {
            contact_rowID = getArguments().getString(EXTRA_CONTACTID);
            //Let's get the contact
            String projection[] = { DBHelper.CONTACTS_ROWID, DBHelper.CONTACTS_UUID, DBHelper.CONTACTS_NAME, DBHelper.CONTACTS_PUBLIC_KEY };
            Cursor contactCursor = getActivity().getContentResolver().query(Uri.withAppendedPath(ContactProvider.CONTENT_URI, String.valueOf(contact_rowID)),projection, null, null, null);
            if (contactCursor.moveToFirst()) {
                contact_id = contactCursor.getLong(contactCursor.getColumnIndex(DBHelper.CONTACTS_ROWID));
                contact_UUID = contactCursor.getString(contactCursor.getColumnIndex(DBHelper.CONTACTS_UUID));
                contact_name = contactCursor.getString(contactCursor.getColumnIndex(DBHelper.CONTACTS_NAME));
            }
        }

        adapter = new MessageListAdapter(getActivity(), null, 0);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.activity_contact_chat, container, false);
        messageList = (ListView) rootView.findViewById(R.id.messages_list);

        messageList.setAdapter(adapter);
        getLoaderManager().initLoader(CONTACT_CHAT_LOADER, null, this);

        /*
        TextView empty = new TextView(getActivity());
        empty = (TextView) messageList.getEmptyView();
        empty.setText(R.string.chat_no_messages);
        empty.setVisibility(View.GONE);
        ((ViewGroup) messageList.getParent()).addView(empty);       
        messageList.setEmptyView(empty);
        */

        EditText message_input_text = (EditText) rootView.findViewById(R.id.chat_message_input);
        message_input_text.clearFocus();

        Button message_input_button = (Button) rootView.findViewById(R.id.details_record_button);
        message_input_button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(getActivity(), "Hi!",Toast.LENGTH_SHORT).show();
            }
        });

        return rootView;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (mActivatedPosition != ListView.INVALID_POSITION) {
            // Serialize and persist the activated item position.
            outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
        }
    }

    @Override
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        String[] projection = {DBHelper.MESSAGES_ROWID, DBHelper.MESSAGES_CONTENT, DBHelper.MESSAGES_CONTENT_LOCATION, DBHelper.MESSAGES_LOCATION, DBHelper.MESSAGES_READ_DATE, DBHelper.MESSAGES_UUID_FROM, DBHelper.MESSAGES_UUID_TO};
        CursorLoader cursorLoader = new CursorLoader(getActivity(), MessageProvider.CONTENT_URI, projection, null, null, null);
        return cursorLoader;
    }
    @Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
        adapter.swapCursor(cursor);
    }
    @Override
    public void onLoaderReset(Loader<Cursor> loader) {
        adapter.swapCursor(null);
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:10:32+00:00Added an answer on June 16, 2026 at 3:10 pm

    Just remove

    android:descendantFocusability="blocksDescendants" 
    

    in main RelativeLayout. You will get the focus in the Edittext.BlockDescendants will prevent the child layouts from getting focus. Check http://developer.android.com/reference/android/view/ViewGroup.html#attr_android:descendantFocusability

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button in a FragmentActivity which, when pressed should open a DialogFragment.
I have a parent FragmentActivity with three child Tab Fragments. When a Submit button
I have a simple contentProvider, a layout with a ListView and a button for
I have a FragmentActivity (main) which creates 3 Fragments and also a menu. Pretty
I have have a FragmentActivity with two tabs which are ListFragment s. Each ListFragment
I have have a FragmentActivity with two tabs which are ListFragment s. Each ListFragment
I have a FragmentActivity support v4 class which implements two side by side (kind
I have a FragmentActivity which sets a main layout with 3 tabs. Each tab
I have a tabhost with 5 tabs which are FragmentActivity . One of them
I have an Activity which extends MapActivity (to show a MapView) and contains a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.