我使用PopUpwindow與textviews中。問題是當我點擊任何textvies時,背景顏色並沒有改變,雖然它在textview被聚焦但不是點擊時改變。textview背景顏色不改變點擊popup windowow
點擊我正在駁回popupwindow,如果我不關閉該popupwindow然後根據選擇背景顏色變化後:
這是我的TextView背景選擇:
<item android:state_focused="true" android:drawable="@drawable/focused" />
<item android:state_pressed="true" android:drawable="@drawable/pressed" />
<item android:drawable="@drawable/priornone" /> <!-- default --> </selector>
在我popupwindow所有我做的是這樣的:
:TextView manage_list = (TextView)popupView.findViewById(R.id.manage_lists);
manage_list.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
Intent myIntent = new Intent(v.getContext(),ManageList.class);
popupWindow.dismiss();
startActivity(myIntent);
}});
爲popupwindow佈局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/pop_menu_bg"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/manage_lists"
android:text="Manage lists"
android:background="@drawable/my_drawable"
>
</TextView>
</LinearLayout>
它非常奇怪的行爲一切運作良好,如果我不關閉popupwindow,但如果我忽略popupwindow單擊textview背景不會更改。
我在做什麼錯了?任何幫助將不勝感激。
感謝您的建議,但它沒有幫助,仍textview背景不會改變點擊。 – kay 2012-07-12 17:07:24
@kay你可以發佈你的佈局xml文件嗎?我相信這個代碼和其他回答您問題的代碼是正確的,所以問題可能在其他地方。 – Angelo 2012-07-12 17:14:43
我發佈了佈局文件。 – kay 2012-07-12 17:37:32