мое приложение содержит «Настройки» активность, которая содержит 2 imagebuttons «назад» и «о», всякий раз, когда я нажмите любую из этих кнопок я получаю:не смог сохранить, какой вид имеет фокус?
«не смогло сохранить какое представление имеет фокус, потому сфокусированного зрения android.widget .LinearLayout @ 4055a9e0 не имеет идентификатора»
XML-код для my_settings:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ll2"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="15" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_margin="8dp"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/settings" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|end"
android:orientation="horizontal" >
<ToggleButton
android:id="@+id/tb1"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="@string/sett1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/border2"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/ll_set_back"
android:layout_margin="3dp"
android:gravity="center"
android:layout_weight="1"
android:orientation="vertical" >
**<ImageButton
android:id="@+id/st_ibt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/action_btn"
android:src="@drawable/back_ic" />**
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/back"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/ll_set_about"
android:layout_margin="3dp"
android:gravity="center"
android:layout_weight="1"
android:orientation="vertical" >
**<ImageButton
android:id="@+id/st_ibt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/action_btn"
android:src="@drawable/about_ic" />**
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Dont обратить внимание на "Scrollview"(я не думаю, что проблема есть), просто посмотреть в конце код для двух кнопок изображения.
и это код Java для настройки:
public class Settings extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.my_settings);
//code...
ImageButton goBack=(ImageButton)findViewById(R.id.st_ibt1);
ImageButton about=(ImageButton)findViewById(R.id.st_ibt2);
goBack.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent=new Intent(Settings.this, MainActivity.class);
startActivity(intent);
//finish();
}
});
about.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent=new Intent(Settings.this, About.class);
startActivity(intent);
//finish();
}
});
}
так, как это исправить? я не понимаю, что значит эта ошибка .. любые предложения
ведь проблема была в прокрутке, он он, моя ошибка :). большое спасибо! @Rey Pham, ты спас меня. в общем, если я не исправлю проблему, что может случиться с моим приложением? – Lena