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

青岛网站建设服务门户网站介绍

青岛网站建设服务,门户网站介绍,jsp网站开发技术,沈阳市工伤网站做实第四次作业-宝宝相册 题目 用Listview建立宝宝相册#xff0c;相册内容及图片可自行设定#xff0c;也可在资料文件中获取。给出模拟器仿真界面及代码截图。 #xff08;参考例4-8#xff09; 创建工程项目 创建名为baby的项目工程#xff0c;最后的工程目录结构如下图所…第四次作业-宝宝相册 题目 用Listview建立宝宝相册相册内容及图片可自行设定也可在资料文件中获取。给出模拟器仿真界面及代码截图。 参考例4-8 创建工程项目 创建名为baby的项目工程最后的工程目录结构如下图所示 res/drawable文件中的i1、i2、i3、i4、i5、i6均为图片即宝宝相册图片网上自行选取照片即可。 res/layout为文件布局文件activity_main.xml为自动生成的自定义布局文件list_item.xml为自定义布局文件 布局文件 创建自定义布局文件list_item.xml文件 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationhorizontalImageViewandroid:idid/news_thumbandroid:layout_width100dpandroid:layout_height100dpandroid:layout_margin5dp/LinearLayoutandroid:orientationverticalandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_marginTop5dpTextViewandroid:idid/news_titleandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize16sp /TextViewandroid:idid/news_infoandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize14spandroid:layout_marginTop5dp//LinearLayout/LinearLayout修改MainActivity.xml布局文件 ?xml version1.0 encodingutf-8? RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeft16dpandroid:paddingRight16dpListViewandroid:idid/listandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent//RelativeLayoutMainActivity文件 package com.example.baby;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle; import android.widget.ListView; import android.widget.SimpleAdapter;import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random;public class MainActivity extends AppCompatActivity {private ListView listView;private SimpleAdapter adapter;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 假设有一个包含数据的ListListMapString, String data new ArrayList();MapString, String item1 new HashMap();item1.put(news_thumb, String.valueOf(R.drawable.i1)); //R.drawable.i1引用照片资源文件item1.put(news_title, 毡帽系列);item1.put(news_info, 此系列服装有点cute像不像小车夫。);data.add(item1);MapString, String item2 new HashMap();item2.put(news_thumb, String.valueOf(R.drawable.i2)); //R.drawable.i2引用照片资源文件item2.put(news_title, 蜗牛系列);item2.put(news_info, 宝宝变成了小蜗牛爬啊爬啊爬啊。);data.add(item2);MapString, String item3 new HashMap();item3.put(news_thumb, String.valueOf(R.drawable.i3));item3.put(news_title, 小蜜蜂系列);item3.put(news_info, 小蜜蜂嗡嗡嗡飞到西飞到东。);data.add(item3);MapString, String item4 new HashMap();item4.put(news_thumb, String.valueOf(R.drawable.i4));item4.put(news_title, 毡帽系列);item4.put(news_info, 此系列服装有点cute像不像小车夫。);data.add(item4);MapString, String item5 new HashMap();item5.put(news_thumb, String.valueOf(R.drawable.i5));item5.put(news_title, 蜗牛系列);item5.put(news_info, 宝宝变成了小蜗牛爬啊爬啊爬啊。);data.add(item5);MapString, String item6 new HashMap();item6.put(news_thumb, String.valueOf(R.drawable.i6));item6.put(news_title, 小蜜蜂系列);item6.put(news_info, 小蜜蜂嗡嗡嗡飞到西飞到东。);data.add(item6);// 定义数据的键与布局文件中组件的映射String[] from {news_thumb, news_title, news_info};int[] to {R.id.news_thumb, R.id.news_title, R.id.news_info};// 创建SimpleAdapteradapter new SimpleAdapter(this, data, R.layout.list_item, from, to);// 关联SimpleAdapter与ListViewlistView findViewById(R.id.list);listView.setAdapter(adapter);// 为ListView添加一个项目点击监听器当点击项目时显示对话框listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {Overridepublic void onItemClick(AdapterView? parent, View view, int position, long id) {// 获取点击项目的数据MapString, String itemData (MapString, String) parent.getItemAtPosition(position);// 从点击项目的数据中提取文本信息以供对话框使用String title itemData.get(news_title);String info itemData.get(news_info);// 创建并显示一个自定义对话框AlertDialog.Builder builder new AlertDialog.Builder(MainActivity.this);builder.setTitle(title).setMessage(info).setPositiveButton(确定, null); // 没有操作的确定按钮AlertDialog dialog builder.create();dialog.show();}});} }修改AndroidManifest.xml文件 activityandroid:name.MainActivityandroid:exportedtrueandroid:labelSimpleAdapterDemo !--修改导航栏名称--intent-filteraction android:nameandroid.intent.action.MAIN /category android:nameandroid.intent.category.LAUNCHER //intent-filter /activity效果展示
http://www.pierceye.com/news/119070/

相关文章:

  • 网站难做吗建设企业网站的需求
  • 网站开发设计文档模板wordpress5.2下载
  • 网站备案后要做什么wordpress 黑色
  • 池州建设机械网站中国房地产100强名单
  • 怎么在虚拟主机上建网站wordpress 更新feed
  • 内设网站wordpress 注册验证
  • 全景网站建设做米业的企业网站
  • 珠海哪个建设网站建设好ui网站界面设计
  • 中国有名的模版网站电商建设网站
  • 网站改域名合肥网站建设企业
  • 建网站需要软件c 怎么做能让窗体访问网站
  • 呼家楼网站建设黄骅市官方网站
  • 空包网站分站怎么做手表网站哪个最好知乎
  • 手机商城建站系统网站建设有关建筑网站建设方案
  • 做网站需要具备的基础条件wordpress 修改后台
  • 网站做点击收费标准重庆建设工业集团
  • wordpress个人网站备案管理广州网站搭建费用
  • 英文网站建设的原因泰安房产信息网网签查询
  • 怎么将网站做成html如何寻找一批做网站的公司
  • 苏州网站建设孙峰南宁站建站时间
  • 海淀手机网站设计公司苏州建设工程有限公司
  • 兰州网站设计制作王妃貌美还狠凶
  • 做新闻微网站有哪些淘宝优惠劵做网站模版
  • 网站维护的意义百度一下官网首页百度
  • 我是做网站怎么赚钱外贸网站google推广
  • 无锡网站seo报价软件开发模型是对软件开发过程的一种规范描述
  • 暴利产品竞价单页网站微信电商小程序开发公司
  • 网站中的搜索功能怎么做怎样在网站做友情链接
  • 新闻单位建设网站的意义怎么和其它网站做友情链接
  • 做哪类网站没有版权问题帮忙做公司网站