2011-02-03 50 views
1

我创建了一个小小部件应用程序。昨天我决定为程序添加更多的功能,所以我需要一个活动,因为小部件看起来不错,但我想在我的应用程序中为用户提供更多信息(listview,按钮,这是我需要的)。 因此,在/ layout文件夹中,我为该活动的图形设计创建了一个“config.xml”。这只有一个textview,不需要编码。如何将活动添加到小部件

然后,我创建了MainActivity.java,这看起来简单得要命:

public class MainActivity extends Activity { 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.config); 
    TextView txt = (TextView) findViewById(R.id.TextView01); 
    txt.setText("Something"); 
} 
} 

的AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.bfarago.hellowidget" 
    android:versionCode="1" 
    android:versionName="1.0"> 
<application android:icon="@drawable/icon" android:label="@string/app_name"> 


    <receiver android:name=".HelloWidget" android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> 
     </intent-filter> 
     <meta-data android:name="android.appwidget.provider" android:resource="@xml/hello_widget_provider" /> 
    </receiver> 
    <service android:enabled="true" android:name=".UpdateService" /> 


    <activity android:name=".MainActivity" 
         android:label="@string/hello"> 
      <intent_filter> 
        <action android:name="android.intent.action.MAIN" /> 
        <category android:name="android.intent.category.LAUNCHER" /> 
      </intent_filter> 
    </activity> 


</application> 

问题是,当我启动该应用我无法在其他应用中看到它的图标。 我错过了什么?

回答

0

的AndroidManifest.xml中指定默认的“德罗伊德”图标应该显示在应用网格 - 默认名称(从RES /值/ strings.xml中)为“用户应用程序”。它在吗?

通过“启动应用程序”你是指小部件还是活动?当然,一项活动通常需要显示并隐藏任何其他图标或应用程序。

相关问题