0
ボタンのセットが必要です。ボタンのフォーカスは、最初に定期的に変更する必要があります.2つのボタンで試してみたいです。これは私のmain.xmlファイルです。ソースコード内のAndroidのオートフォーカスの変更
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/number_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.72"
android:focusable="true"
android:gravity="center"
android:text="@string/number"
android:textSize="10pt" android:clickable="true"
android:focusableInTouchMode="true"/>
<Button
android:text="@string/contact"
android:textSize="10pt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/contact_button"
android:layout_weight="1" android:layout_gravity="center"
android:focusable="true" android:gravity="center"
android:focusableInTouchMode="true"/>
</LinearLayout>
私はFOCUS_LEFT、RIGHTおよび他のすべてのオプションを使用していたが、私は、実行時例外を取得しています。誰もがそれを投稿だけでなく、タイマーのオプションを設定する方法を知っていれば姿勢がここにここに
、この問題を整理するために私を助けてlayout.Please線形に垂直に設定されているコード
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class HelloandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Object o=null;
// o.toString();
// TextView tv = new TextView(this);
// tv.setText("Hello Andriod");
setContentView(R.layout.main);
Button mybtn= (Button)findViewById(R.id.number_button);
mybtn.requestFocus();
try
{
Button mybtn2= (Button)mybtn.focusSearch(View.FOCUS_DOWN);
mybtn2.requestFocus();
}
catch(Exception e)
{
Log.e("focus change","focus failed",e);
}
}
}
どのようなRuntimeException? StackTraceをここに配置できますか? –
皆さん、私の質問にできるだけ早く答えてください。私のプロジェクトには必要なので、巨大な助けになるでしょう。 –
@Marek sebera:NULLポインタ例外 –