Есть такой layout, всё работает, кроме кнопки @+id/topic_button_send, она не реагирует на нажатия (не работает), будто что-то её не даёт. Кнопка "Повторить" работает нормально. В чём здесь может быть проблема? И ещё, я нормально сделал разметку или криво?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topic_refresh"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
tools:context="ru.redozote.profiwm.TopicActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:indeterminate="true"
android:id="@+id/topic_listView" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/topic_progressBar"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<LinearLayout
android:id="@+id/topic_error"
android:gravity="center"
android:visibility="gone"
android:orientation="vertical"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Ошибка при получении данных"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/topic_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Повторить" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/shape_post_form"
android:padding="5dp">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/topic_editText_message"
android:layout_toLeftOf="@+id/topic_button_send"
android:layout_toStartOf="@+id/topic_button_send" />
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="Отпр."
android:id="@+id/topic_button_send"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/topic_editText_message"
android:background="@drawable/shape_post_form_button" />
</RelativeLayout>
</RelativeLayout>
Вот часть кода из TopicActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_topic);
getActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.topic_fragment, new PlaceholderFragment())
.commit();
}
Bundle extras = getIntent().getExtras();
topic = (Topic) extras.getSerializable("topic");
setTitle(topic.getTitle());
user = new User(this);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.topic_refresh);
progressBar = (ProgressBar) findViewById(R.id.topic_progressBar);
mainError = (LinearLayout) findViewById(R.id.topic_error);
listView = (ListView) findViewById(R.id.topic_listView);
button = (Button) findViewById(R.id.topic_button);
registerForContextMenu(listView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new LoadPostsTask(url, 1).execute();
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new LoadPostsTask(url, 1).execute();
}
});
message = (EditText) findViewById(R.id.topic_editText_message);
sendButton = (Button) findViewById(R.id.topic_button_send);
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// sendMessage(message.getText().toString());
// message.setText("");
Toast.makeText(getApplicationContext(), "Кнопка нажата", Toast.LENGTH_SHORT).show();
}
});
ArrayList<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("id", String.valueOf(topic.getId())));
url = URLGenerator.create("topic", user.getUsername(), user.getPassword(), params);
new LoadPostsTask(url, 1).execute();
}