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>
问题是,当我启动该应用我无法在其他应用中看到它的图标。 我错过了什么?