我没有收到来自我的按钮的点击事件。我想知道为什么。
我有一个 LinearLayout,在操作栏的顶部有一个包含布局,下面有一个按钮。我无法接收事件
- 操作栏上的“mylocation 图标”,就在下方
- 下一步按钮
- 放大/缩小按钮
我在这里想念什么?
主布局 location.xml
<?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" >
<include
android:id="@+id/actionbar"
android:layout_alignParentTop="true"
layout="@layout/actionbar" />
<Button
android:id="@+id/next"
<!-- removed unnecesary attr's -->
android:background="#f6461d"
android:clickable="true"
android:enabled="true"
android:text="Next"/>
</RelativeLayout>
操作栏
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_alignParentTop="true"
android:background="#EEeeeee4"
<!-- removed unnecesary attr's --> >
<LinearLayout
<!-- removed unnecesary attr's -->
android:orientation="horizontal" >
<Button
android:id="@+id/icruiseon"
<!-- removed unnecesary attr's -->
android:background="@drawable/curbcablogo" />
<Button
android:id="@+id/refresh"
<!-- removed unnecesary attr's -->
android:background="@drawable/refresh" />
<ImageView
android:id="@+id/connectStatus"
<!-- removed unnecesary attr's -->
android:src="@drawable/disconnect" />
<ImageView
android:id="@+id/busy"
<!-- removed unnecesary attr's -->
android:clickable="false"
android:src="@drawable/busy" />
<TextView
android:id="@+id/subscriberInbox"
<!-- removed unnecesary attr's -->
android:background="@drawable/incomingprovider" />
</LinearLayout>
<LinearLayout
<!-- removed unnecesary attr's --> >
<TextView
android:id="@+id/currentAddress"
<!-- removed unnecesary attr's -->
android:text="Receiving address....." />
<ImageView
android:id="@+id/whereAmI"
<!-- removed unnecesary attr's -->
android:src="@drawable/mylocation" />
</LinearLayout>
</LinearLayout>
我的活动档案
public class MyActivity {
onCreate() {
setContentView(R.layout.location) ;
next = (Button) this.findViewById(R.id.next);
next.setOnClickListener(this);
whereAmI = (ImageView) this.findViewById(R.id.whereAmI);
whereAmI.setOnClickListener(this) ;
@Override
public void onClick(View v) {
if (v == next) {
Toast.makeText(this, "searching", Toast.LENGTH_LONG).show() ;
new Search(this, source, destination).execute(null);
} else if (v == whereAmI) {
Toast.makeText(this, "centering", Toast.LENGTH_LONG).show() ;
location.getController().setCenter(source);
new GetGeoAddress(this, source).execute(null);
}
}
另一个活动
public class HomeActivity extends MyActivity {
onCreate() {
//No setContentView here ; I expect that the super class MyActivity will setContentView.
编辑:从布局和代码中删除了 MapView,以消除和调试。我仍然没有收到点击事件。我在这里想念什么?
编辑2:在上面添加了一些更改,我怀疑这与活动继承有关。我知道我在这里缺少一些基本的东西。它是什么 ?