-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
ImageView image = (ImageView)findViewById(R.id.header);
image.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Toast.makeText(CustomWindowTitle.this, "This is sample", Toast.LENGTH_SHORT).show();
return false;
}
});
}
Window_title.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#323331">
<ImageView
android:id="@+id/header"
android:src="@drawable/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
が、これはあなたのために役立つことができます願っています。私はそれを得た

更新
- 以下の私の出力を参照してください。これはあなたを助け
public class MyCustomTab2Activity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
//Tab Content
setContentView(R.layout.my_tab_home);
//custom title bar content
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.logintitle);
ImageView imag = (ImageView) findViewById(R.id.iv_logout);
imag.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
......
...........
}
}
希望 - あなたはあなたのコードの変更以下のようにしてください画像のOnclickListener
後のカスタムタイトルを宣言されています。
はい。 .. –
あなたのコードを試しました。私もnullpointer例外を取得しています。私の更新答えを試してみてください。それは有用かどうか? – Praveenkumar