本文介绍了不可能点击一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在与被显示在屏幕上的一个按钮一个奇怪的问题,但是我无法点击。这并不是说在的onClick
事件不点火,似乎身体不反应的点击,因为如果它有它的顶部透明层。
I'm having a weird issue with a button that is being shown on screen, but that I can't click. It is not that the onClick
event is not firing, it seems that physically it does not react to clicks, as if it had a transparent layer on top of it.
主要活动
其中,它是建立在:
The main Activity
where it is built on:
public class MusicList extends Activity implements OnClickListener {
...
@Override
public void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setContentView(R.layout.mymusic);
this.myTabHost = (TabHost)this.findViewById(R.id.th_set_menu_tabhost);
this.myTabHost.setup();
TabSpec ts = myTabHost.newTabSpec("TAB_TAG_1");
ts.setIndicator("Media Item",getResources().getDrawable(R.drawable.music));
ts.setContent(R.id.media_item_tab);
try {
relativeLayout = (RelativeLayout) myTabHost.findViewById(android.R.id.tabcontent).findViewById(R.id.media_item_tab);
} catch (NullPointerException e) {
Log.e(this.getClass().getSimpleName(),"Layout is not correct",e);
}
Button button = (Button)relativeLayout.findViewById(R.id.play_button);
// button.setClickable(true);
button.setOnClickListener(this);
myTabHost.addTab(ts);
}
@Override
public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(itemData.get("ITEM_URL"))));
}
}
布局,这是完美的显示在屏幕上是这样的:
The layout, which is shown perfect on screen is like this:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/th_set_menu_tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="65px">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/media_item_tab"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/media_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textColor="#40A5D9"
android:gravity="center"
android:layout_alignParentTop="true"
android:singleLine="true"
android:ellipsize="marquee"
android:text="Title"
>
</TextView>
<ImageView
android:id="@+id/media_cover"
android:layout_width="fill_parent"
android:layout_height="180px"
android:gravity="center"
android:layout_below="@+id/media_title"
android:src="@drawable/geniocover"
>
</ImageView>
<TextView
android:id="@+id/media_author"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#86CCF3"
android:gravity="center"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_below="@+id/media_cover"
android:text="Author"
>
</TextView>
<TextView
android:id="@+id/media_album"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#DAFFFF"
android:gravity="center"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_below="@+id/media_author"
android:text="Album (Year)"
>
</TextView>
<Button
android:id="@+id/play_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Play"
android:textColor="#003983"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="center"
android:layout_below="@+id/media_album"
android:clickable="true"
>
</Button>
</RelativeLayout>
<ListView
android:id = "@+id/tablist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>
</TabHost>
有什么建议?
谢谢!
推荐答案
您有一个的FrameLayout
有两个孩子时,它仅用于主机之一。在的ListView
最后补充说,最终会在顶部,很可能接收所有的输入。
You have a FrameLayout
with two children when it's only intended to host one. The ListView
was last added, will end up on top and is probably receiving all of your input.
这篇关于不可能点击一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!