论坛首页 移动开发技术论坛

Activity & Context

浏览 2852 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-01-12   最后修改:2010-01-12
to import Activity or Context as following.

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!
论坛首页 移动开发技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics