【问题标题】:Android: opening activity from widget as dialog and disabling the backgroundAndroid:从小部件打开活动作为对话框并禁用背景
【发布时间】:2014-02-02 17:17:02
【问题描述】:

我正在处理小部件项目,当我触摸小部件时,会出现一个样式类似于对话框的新活动。主活动打开,对话框样式的活动出现,当我触摸主活动时,对话框样式的活动消失。 1)有没有办法禁用活动?要么 2)是否可以在不打开活动的情况下打开对话框样式的活动?

这是我的 BroadcastReceiver 中的 onReceive 类

public void onReceive(Context context, Intent intent)
{
    Log.i(TAG,"In onReceive");
    if(intent.getAction().equals(INTENT_ACTION))
    {
        Intent mIntent = new Intent(context,sendActivity.class);
        mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(mIntent);     
    }
}

对话框样式的活动

<?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:focusable="true"
    android:focusableInTouchMode="true">

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="5dp" />

    <TextView
        android:id="@+id/tvdialogTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textColor="#FFF" 
        android:layout_toRightOf="@+id/image"/>

    <TextView
        android:id="@+id/tvStatus01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textColor="#FFF" />

    <TextView
        android:id="@+id/tvStatus02"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textColor="#FFF"/>

     <Button
        android:id="@+id/btnWidgetDialogCancel"
        android:layout_width="100px"
        android:layout_height="wrap_content"
        android:text="Cancel"
        android:layout_marginTop="5dp"
        android:layout_marginRight="5dp"
        android:layout_below="@+id/image"
        />

</RelativeLayout>

我的清单的一部分

<activity
    android:name="com.example.widget.sendActivity"
    android:theme="@android:style/Theme.Dialog"
    android:excludeFromRecents="true">
</activity>

提前致谢。

【问题讨论】:

    标签: android android-activity dialog widget


    【解决方案1】:

    如果其他人有兴趣,我会使用这条线

    this.setFinishOnTouchOutside(false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多