首页 >> 数码 >

如何使用integer 如何使用Intent

2022-07-12 16:15:16 来源: 用户: 

大家好,我是云百科的客服小柏,我来为大家解答以上问题。如何使用integer,如何使用Intent很多人还不知道,现在让我们一起来看看吧!

解答:

1、 main.xml?xmlversion='1.0'编码='utf-8'?

2、 linearlayoutxmlns:Android='http://模式。安卓。'com/apk/RES/Android'

3、 Android:方向='垂直'

4、 Android:layout_width='fill_parent'

5、 Android:layout_height='fill_parent'

6、 带边框的

7、 Android:layout_width='fill_parent'

8、 Android:layout_height='wrap_content'

9、 Android:text='@string/hello'

10、 /

11、 纽扣

12、 android:text='测试行动属性'

13、 android:id='@id/getBtn'

14、 Android:layout_width='wrap_content'

15、 Android:layout_height='wrap_content'

16、 /

17、 /线性布局

18、 strings.xml

19、 ?xmlversion='1.0'编码='utf-8'?

20、 资源

21、 stringname='你好'测试行动属性/string

22、 stringname='app_name'intentactiondemo/string

23、 /资源

24、 MainActivity.java

25、 包com。安卓。行动。活动;

26、 重要机器人。app。活动;

27、 重要的机器人。内容。意图;

28、 重要的机器人。OS。捆绑;

29、 重要的机器人。查看。查看;

30、 重要的机器人。查看。查看。onclick侦听器;

31、 重要的机器人。小部件。按钮;

32、 publicsclassmainactivityextendssactive{

33、 privateButtongetBtn

34、 @覆盖

35、 publicfoidoncreate(BundlesavedInstanceState){

36、 超级棒。oncreate(savedInstanceState);

37、 setContentView(r.layout。main);

38、 获取BTN=(Button)findViewById(r.id。得到BTN);

39、 getbtn。setonclicklistener(newOnClickListener(){

40、 @覆盖

41、 publicvoidonClick(vievv){

42、 intentintent=newintent();

43、 intent.setAction(Intent.ACTION_GET_CONTENT);//设置意图属性

44、 意图。settype('vnd。安卓。光标。项目/电话’);//设置意图类型属性

45、 //主要是获取通讯录的内容

46、 开始活动(意图);//启动活动

47、 }

48、 });

49、 }

50、 }

51、 运行之后的结果

本文到此讲解完毕了,希望对大家有帮助。

  免责声明:本文由用户上传,与本网站立场无关。财经信息仅供读者参考,并不构成投资建议。投资者据此操作,风险自担。 如有侵权请联系删除!

 
分享:
最新文章
站长推荐