2016-11-23 3 views
0

Я пытаюсь сделать групповое сообщение с ним, и в настоящее время я пытаюсь заставить мой макет работать. У меня есть фрагмент, который используется для обмена сообщениями, чтобы пользователи могли использовать боковое меню переключаться между вещами.FloatingActionButton и EditText не доступны для просмотра

Моя проблема в том, что клавиатура не появляется, когда я нажимаю на текстовое поле редактирования. и что ничего не происходит, когда нажмите кнопку плавающих действий

Спасибо вам так много заранее

У меня есть следующий XML.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/chat_main" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity"> 

    <android.support.design.widget.FloatingActionButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:clickable="true" 
     android:id="@+id/fab" 
     android:src="@drawable/ic_send_white_24dp" 
     android:tint="@android:color/white" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" 
     app:fabSize="mini" /> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_toLeftOf="@id/fab" 
     android:clickable="true" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentStart="true"> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Message" 
      android:id="@+id/input" /> 
    </android.support.design.widget.TextInputLayout> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentStart="true" 
     android:layout_above="@id/fab" 
     android:dividerHeight="16dp" 
     android:divider="@android:color/transparent" 
     android:id="@+id/list_of_messages" 
     android:layout_marginBottom="16dp"/> 
</RelativeLayout> 

В моем классе Фрагмент У меня есть только onCreateView и OnCreate

@Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     mView = inflater.inflate(R.layout.chat_main, container, false); 
     ListView listOfMessages = (ListView) mView.findViewById(R.id.list_of_messages); 
     fab = (FloatingActionButton) mView.findViewById(R.id.fab); 
     fab.bringToFront(); 
     input = (EditText) mView.findViewById(R.id.input); 
     fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Toast.makeText(getActivity(), "clicked", Toast.LENGTH_LONG).show(); 

       input.setEnabled(true); 
       // Read the input field and push a new instance 
       // of ChatMessage to the Firebase database 
       mMessagesDatabase 
         .push() 
         .setValue(new ChatMessage(input.getText().toString(), 
           mUser.getDisplayName()) 
         ); 
       // Clear the input 
       input.setText(""); 
      } 
     }); 
     adapter = new FirebaseListAdapter<ChatMessage>(getActivity(), ChatMessage.class, 
       R.layout.message, mMessagesDatabase) { 
      @Override 
      protected void populateView(View v, ChatMessage model, int position) { 
       // Get references to the views of message.xml 
       TextView messageText = (TextView) v.findViewById(R.id.message_text); 
       TextView messageUser = (TextView) v.findViewById(R.id.message_user); 
       TextView messageTime = (TextView) v.findViewById(R.id.message_time); 
       // Set their text 
       messageText.setText(model.getMessageText()); 
       messageUser.setText(model.getMessageUser()); 
       // Format the date before showing it 
       messageTime.setText(DateFormat.format("dd-MM-yyyy (HH:mm:ss)", 
         model.getMessageTime())); 
      } 
     }; 
     listOfMessages.setAdapter(adapter); 
     return mView; 
    } 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     mUser = FirebaseAuth.getInstance().getCurrentUser(); 
     mMessagesDatabase = FirebaseDatabase.getInstance().getReference().child("Messages"); 


    } 

ответ

0

Добавить android:focusable="true" и android:focusableInTouchMode="true" в свой EditText

+0

Это не исправить .... –

Смежные вопросы