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

微博营销网站源码怎样创建一个平台

微博营销网站源码,怎样创建一个平台,国际网站如何做seo,公司注册资金实缴和认缴的区别实训9 数据存储和访问 一、【实训目的】 1、 SharedPreferences存储数据; 2、 借助Java的I/O体系实现文件的存储#xff0c; 3、使用Android内置的轻量级数据库SQLite存储数据; 二、【实训内容】 1、实现下图所示的界面#xff0c;实现以下功能#xff1a; 1#xff…实训9  数据存储和访问 一、【实训目的】 1、 SharedPreferences存储数据; 2、 借助Java的I/O体系实现文件的存储 3、使用Android内置的轻量级数据库SQLite存储数据; 二、【实训内容】 1、实现下图所示的界面实现以下功能 1用SharedPreferences类当点击”写入xml文件”按钮, 把“输入你想写入内容”控件中的数据写入到login.xml文件中 2用SharedPreferences类当点击”读取内容”按钮, 把login.xml文件中的数据读到到一个TextView中,并显示内容 具体步骤 MainActivity源文件 package com.example.hahah;import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream;import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText;public class MainActivity extends Activity {private Button write, read;private EditText writeText, readText;private String fileName context.txt;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);write (Button) findViewById(R.id.btnwritexml);read (Button) findViewById(R.id.btnreadxml);writeText (EditText) findViewById(R.id.writecontent);readText (EditText) findViewById(R.id.readcontent);write.setOnClickListener(new OnClickListener() {public void onClick(View arg0) {write(writeText.getText().toString());}});read.setOnClickListener(new OnClickListener() {public void onClick(View arg0) {readText.setText(read());}});}public String read() {StringBuilder sbBuilder new StringBuilder();byte[] buffer new byte[64];int hasRead;try {FileInputStream fis openFileInput(fileName);while ((hasRead fis.read(buffer)) ! -1) {sbBuilder.append(new String(buffer, 0, hasRead));}} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}return sbBuilder.toString();}public void write(String str) {try {FileOutputStream fos openFileOutput(fileName, Context.MODE_APPEND);PrintStream ps new PrintStream(fos);ps.print(str);ps.close();try {fos.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}} catch (FileNotFoundException ex) {ex.printStackTrace();}}Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}} Activity_main源代码 TableLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthfill_parentandroid:layout_heightfill_parentandroid:orientationvertical android:stretchColumns2TableRowEditTextandroid:idid/writecontentandroid:layout_width0dp android:layout_heightwrap_contentandroid:layout_weight1.0 android:hint输入你想写入的内容 //TableRowTableRow Buttonandroid:idid/btnwritexmlandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text写入xml文件 //TableRowTableRowEditTextandroid:idid/readcontentandroid:layout_width0dp android:layout_heightwrap_content//TableRowTableRow Buttonandroid:idid/btnreadxmlandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text读取内容 //TableRowTableRow Buttonandroid:idid/btnwritetxtandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text写入login.txt文件 //TableRowTableRow Buttonandroid:idid/btnwritesqlandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_column0 android:text写入数据库 //TableRow /TableLayout 运行结果截图 附注该专栏是博主上学时的实训项目可供访客练习与参考。代码质量不是很好但能实现仅供参考
http://www.tj-hxxt.cn/news/137563.html

相关文章:

  • 曲靖做网站价格上海市网站
  • 如何免费建购物网站有哪些可以做包装袋的网站
  • 麦包包的网站建设分站式二手车网站源码
  • 东方市住房和城乡建设局网站有什么学做木工的网站吗
  • 做网站前必须设计原型吗湛江网站建设哪家好
  • 网站前期准备工作山西省最新干部调整
  • 服装代销的网站源码建一个网站的价格
  • 南昌做网站设计产品推广方案要包含哪些内容
  • 一流小说网站模板做网站卖假名牌违法吗
  • 毕业设计网站设计步骤中国机械加工信息网
  • 外国人做旅游攻略网站优化好的网站
  • 如何做电影下载网站网上运营培训班
  • 青岛建站c 网站开发 vs2012
  • 惠州seo博客seo快速优化排名
  • 炫酷做网站背景图潮州有没有做网站的人
  • 温州建设局网站林南飞宜都网站seo
  • 网站建设与管理维护书籍怎么在微信里创建公众号
  • 网络推广网站公司wordpress网站弹窗插件
  • 陕西十二建设有限公司网站哪个网站可以做临时工
  • 苏州建网站要多少钱怎么提高自己网站的流量
  • 做app的网站有哪些功能吗html网页制作下载
  • 单页网站在线制作吉林省 网站建设
  • 广州网站建设快速排名公司网站无法收录
  • 网站前端工程师手机端网站seo
  • 数码网站建设论文福州网站建设 找燕狂徒 05
  • 关于公司网站的建设的问卷德宏企业网站建设
  • 公司网站兰州建设需要多少钱东莞网站网络公司
  • 有特点的个人网站网页布局设计说明
  • 西安有哪些大公司华企网站建设推广优化
  • wordpress陌陌主题搜索引擎优化seo论文