решено - изменение layout_height на wrap_content во внутренней компоновке помогло
Я начал играть с разработкой Android вчера, и у меня есть довольно простой вопрос относительно встраивания макетов.Когда я встраиваю один LinearLayout в другой и помещаю в него Button, метод onClick не вызывается.Если я опущу второй LinearLayout, все работает нормально.У вас есть идеи, что я делаю неправильно?
Мой файл макета следует.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/info"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/prompt"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/frequency"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="numberDecimal"
/>
<Button
android:id="@+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/submit"
android:onClick="handleSubmit"
/>
</LinearLayout>
<TextView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
И код:
package pl.test.android.step;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Button;
public class Step extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void handleSubmit(View view)
{
TextView resultObj = (TextView) findViewById(R.id.result);
resultObj.setText("click");
}
}