я реализовал пользовательский заголовок моей деятельности:пользовательский заголовок андроида OnClick, неправильный идентификатор называется
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#3a5894" >
<LinearLayout
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:id="@+id/left_button_title_bar_main_content_fragment"
android:background="#90C3D4"
android:onClick="onClickTitleBar">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#90C3D4"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:id="@+id/center_textview_title_bar"
android:onClick="onClickTitleBar">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="15dp"
android:text="Quick Notes"
android:textColor="#ffffff"/>
</LinearLayout>
</RelativeLayout>
Моя реализация деятельности:
public class MainActivity extends Activity implements OnClickListener {
private LinearLayout leftButtonInTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// custom title
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// full screen activity
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
// custom title bar
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);
leftButtonInTitle = (LinearLayout) findViewById(R.id.left_button_title_bar_main_content_fragment);
и метод, где я хотел бы, чтобы справиться нажмите
public void onClickTitleBar(View v) {
int id = v.getId();
Log.e("","id : "+id);
Log.e("","button id: " + R.id.left_button_title_bar_main_content_fragment);
}
и я внедрил v.getId и фактический идентификатор linearlayout. И я понял, что идентификаторы не совпадают.
вот лог:
E/﹕ id 2131493001
E/﹕ button id: 2131493000
Как вы можете видеть, что номера не совпадают.
Любая идея, почему это происходит?
Любая помощь приветствуется.