爲了保持在中央的文字試圖用機器人:layout_centerInParent = 「真」 DNT採用Android:layout_marginLeft = 「150dp」
和對於TextView中要點擊
tv.setText(Html
.fromHtml("<a href='Banana'>Banana</a>"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
// Performing action on TouchListener of ForgotPassword
tvforgotpwd.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Intent Forgotpwdintent = new Intent();
Forgotpwdintent.setClass(getApplicationContext(),
Kicthenscreen.class);
startActivity(Forgotpwdintent);
return true;
}
});
看這個鏈接它可能有用...... http://coderzheaven.com/2011/05/textview-with-link-in-android/
XML文件,我試圖用相對佈局是..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/textView1"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/textView2"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/textView3"
android:text="TextView" />
</RelativeLayout>
,我在Java文件寫這樣的..
TextView tv=(TextView)findViewById(R.id.textView3);
tv.setText(Html.fromHtml("<a href='Banana'>Banana</a>"));
tv.setClickable(true);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "hai", Toast.LENGTH_LONG).show();
return true;
}
});
我的佈局對準唯一的中心..
thanx的幫助爵士 – Android 2012-02-29 07:57:31
日Thnx這有助於但沒有完全達到我的解決方案 – Android 2012-02-29 08:02:20