按钮打开Activity

1,先在里设置

 <activity android:name=".TextActivity1">
            <intent-filter>
                <action android:name="com.han.action.test1"/>

                <category android:name="com.han.category.test1"/>
            </intent-filter>
        </activity>

2,设置一个Button

<Button
        android:text="隐式打开Ac"
        android:layout_gravity="fill"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:onClick="anniu4"/>

3,编写一个方法实现意图(隐式意图)

 

 public void anniu4(View v)
    {
        //定义隐式意图
        Intent intent=new Intent("com.han.action.test1");

        intent.addCategory("com.han.category.test1 ");
        startActivity(intent);
    }

 

posted @ 2016-04-26 10:01  百事没事  阅读(296)  评论(0编辑  收藏  举报