[英]FloatingActionButton and EditText not clickable
I am trying to do a group-message of sorts with and I'm currently trying to get my layout working.I have a fragment that is used for the messaging so that users can use a side menu to switch between things. 我正在尝试使用某种分组消息,目前正在尝试使布局正常工作。我有一个用于消息传递的片段,以便用户可以使用侧面菜单在事物之间进行切换。
My problem is that the keyboard does not come up when i click on the edit text field. 我的问题是,当我单击编辑文本字段时,键盘没有弹出。 and that nothing happens which the click the floating action button 单击浮动操作按钮没有任何反应
Thank you so much in advance 提前谢谢你
I have the following xml. 我有以下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>
In my Fragment class I have just the onCreateView and onCreate 在我的Fragment类中,我只有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");
}
将android:focusable="true"
和android:focusableInTouchMode="true"
到您的EditText
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.