to import Activity or Context as following.
How to do:
1. public class MyExample extends Activity.
* MyExample is main entrance of this application
2. public class MySample
3. How to new MySample instance.
4. How to use activity or context.
That's all!
How to do:
1. public class MyExample extends Activity.
<activity android:name=".SystemUpApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>* MyExample is main entrance of this application
2. public class MySample
public class MySample{
Activity activity;
Context context;
public MySample(Activity a,Context c) {
activity = a;
context = c;
3. How to new MySample instance.
MySample sample = new MySample(this,this);
4. How to use activity or context.
TextView tv = new TextView(activity);
That's all!
本文介绍了如何在Android应用中设置启动入口,包括定义主Activity、使用Intent过滤器指定MAIN动作和LAUNCHER类别,以及如何在Activity内部通过Context进行组件初始化。
1374

被折叠的 条评论
为什么被折叠?



