当前位置: 首页 > news >正文

定制网站建设公司费用/seo排名官网

定制网站建设公司费用,seo排名官网,自己做的网页怎么发布,新浪网今日乌鲁木齐新闻代码编写 做好准备工作后,终于可以开始写我们的hello android了,在开始编写代码之前,我们先了解几个文件: res/layout/main.xml App主窗体布局文件,你的应用长什么样都在这边定义,有Design和Text两种模式 r…

代码编写

做好准备工作后,终于可以开始写我们的hello android了,在开始编写代码之前,我们先了解几个文件:

res/layout/main.xml App主窗体布局文件,你的应用长什么样都在这边定义,有Design和Text两种模式

res/values/strings.xml 可以理解为i18n文件,这个文件用来存放程序调用的各种字符串

src/com/example/helloandroid/MyActivity.java 这个就是我们的主程序类,等下要实现的功能都在这个文件里添加

首先为应用添加一个id为hellotextView的textview和一个id为hellobutton的button,mail.xml 代码如下:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TextViewandroid:layout_width="fill_parent"android:layout_height="180dp"android:text="@string/default_message"android:id="@+id/hellotextView" android:textColor="#00ff00" android:gravity="center"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button_send"android:id="@+id/hellobutton" android:layout_gravity="center"/>
</LinearLayout>


代码和控件用到的字符串定义如下:

<?xml version="1.0" encoding="utf-8"?>
<resources><string name="app_name">helloandroid by hiwanz</string><string name="button_send">Say something</string><string name="default_message">Click button below!</string><string name="interact_message">You just clicked on the Button!</string>
</resources>



主程序中定义button点击后改变textview显示的文本,并且弹出Toast提示信息,代码如下:

package com.example.helloandroid;import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;public class MyActivity extends Activity {/*** Called when the activity is first created.*/@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);//得到按钮实例Button hellobtn = (Button)findViewById(R.id.hellobutton);//设置监听按钮点击事件hellobtn.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {//得到textview实例TextView hellotv = (TextView)findViewById(R.id.hellotextView);//弹出Toast提示按钮被点击了Toast.makeText(MyActivity.this,"Clicked",Toast.LENGTH_SHORT).show();//读取strings.xml定义的interact_message信息并写到textview上hellotv.setText(R.string.interact_message);}});}}


代码写好后,电脑通过USB数据线连接手机,手机系统设置里的开发人员选项里打开USB调试,在IDE中直接点Run就可以在手机上看到运行的效果了。

helloandroid-1

helloandroid-2

http://www.jmfq.cn/news/4883941.html

相关文章:

  • 网站首页轮播怎么做/树枝seo
  • 郑州餐饮网站建设公司排名/广告推广渠道有哪些
  • 设计网站的结构时下面哪个方法不好/软文范例300字
  • 网络营销师培训学校/seo工具在线访问
  • 百度多久收录一次网站/汕头疫情最新消息
  • 可以让外国人做问卷调查的网站/网站关键词百度自然排名优化
  • wordpress手机端/黑帽seo优化软件
  • 扬中网站建设价格/厦门关键词优化企业
  • 百度做网站的费用/药品销售推广方案
  • 政府网站官网/新闻今日要闻
  • 做网站如何与腾讯合作/信息流优化师发展前景
  • 棋牌源码之家/百度seo不正当竞争秒收
  • ueditor是做网站的吗/谷歌seo站内优化
  • 想开网站怎样做/seo蜘蛛池
  • 爱站seo工具包/精准营销平台
  • 学校网站模板 html/可以进入任何网站的浏览器
  • 嵊州哪里可以做网站/建网站用什么工具
  • html网站登录界面模板下载/怎么做起泡胶
  • 贵州网站建设推荐/网站内部seo
  • Java做网站的学习路线/网店推广常用的方法
  • 成都建站哪家好/建设企业营销型网站
  • 做网站平台接单/百度seo公司兴田德润
  • 桂林象鼻山是什么地貌/网站seo关键词设置
  • 厦门谁需要网站建设/漯河网络推广哪家好
  • 建设网站规模与类别/合肥网络推广软件系统
  • 做学分网站/百度权重是怎么来的
  • 网站建设宣传广告语/百度指数怎么用
  • 上海专业的网站公/火蝠电商代运营公司
  • 厦门集团网站建设/直播:韩国vs加纳直播
  • wordpress音乐播放界面/百度seo关键词排名技术