国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

各省備案網(wǎng)站怎么用模板做網(wǎng)站

各省備案網(wǎng)站,怎么用模板做網(wǎng)站,薊縣網(wǎng)站建設(shè),自適應(yīng)網(wǎng)站開發(fā)公司第四次作業(yè)-寶寶相冊 題目 用Listview建立寶寶相冊,相冊內(nèi)容及圖片可自行設(shè)定,也可在資料文件中獲取。給出模擬器仿真界面及代碼截圖。 (參考例4-8) 創(chuàng)建工程項目 創(chuàng)建名為baby的項目工程,最后的工程目錄結(jié)構(gòu)如下圖所…

第四次作業(yè)-寶寶相冊

題目

用Listview建立寶寶相冊,相冊內(nèi)容及圖片可自行設(shè)定,也可在資料文件中獲取。給出模擬器仿真界面及代碼截圖。 (參考例4-8)

創(chuàng)建工程項目

創(chuàng)建名為baby的項目工程,最后的工程目錄結(jié)構(gòu)如下圖所示:

image-20231027171437431

res/drawable文件中的i1、i2、i3、i4、i5、i6均為圖片,即寶寶相冊圖片,網(wǎng)上自行選取照片即可。

res/layout為文件布局文件,activity_main.xml為自動生成的自定義布局文件,list_item.xml為自定義布局文件

布局文件

  1. 創(chuàng)建自定義布局文件list_item.xml文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"><ImageViewandroid:id="@+id/news_thumb"android:layout_width="100dp"android:layout_height="100dp"android:layout_margin="5dp"/><LinearLayoutandroid:orientation="vertical"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="5dp"><TextViewandroid:id="@+id/news_title"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="16sp" /><TextViewandroid:id="@+id/news_info"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="14sp"android:layout_marginTop="5dp"/></LinearLayout></LinearLayout>
    
  2. 修改MainActivity.xml布局文件

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingLeft="16dp"android:paddingRight="16dp"><ListViewandroid:id="@+id/list"android:layout_width="match_parent"android:layout_height="match_parent"/></RelativeLayout>
    

MainActivity文件

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);// 假設(shè)有一個包含數(shù)據(jù)的ListList<Map<String, String>> data = new ArrayList<>();Map<String, 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);Map<String, 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);Map<String, String> item3 = new HashMap<>();item3.put("news_thumb", String.valueOf(R.drawable.i3));item3.put("news_title", "小蜜蜂系列");item3.put("news_info", "小蜜蜂,嗡嗡嗡,飛到西,飛到東。");data.add(item3);Map<String, 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);Map<String, String> item5 = new HashMap<>();item5.put("news_thumb", String.valueOf(R.drawable.i5));item5.put("news_title", "蝸牛系列");item5.put("news_info", "寶寶變成了小蝸牛,爬啊爬啊爬啊。");data.add(item5);Map<String, String> item6 = new HashMap<>();item6.put("news_thumb", String.valueOf(R.drawable.i6));item6.put("news_title", "小蜜蜂系列");item6.put("news_info", "小蜜蜂,嗡嗡嗡,飛到西,飛到東。");data.add(item6);// 定義數(shù)據(jù)的鍵與布局文件中組件的映射String[] from = {"news_thumb", "news_title", "news_info"};int[] to = {R.id.news_thumb, R.id.news_title, R.id.news_info};// 創(chuàng)建SimpleAdapteradapter = new SimpleAdapter(this, data, R.layout.list_item, from, to);// 關(guān)聯(lián)SimpleAdapter與ListViewlistView = findViewById(R.id.list);listView.setAdapter(adapter);// 為ListView添加一個項目點擊監(jiān)聽器,當(dāng)點擊項目時顯示對話框listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {// 獲取點擊項目的數(shù)據(jù)Map<String, String> itemData = (Map<String, String>) parent.getItemAtPosition(position);// 從點擊項目的數(shù)據(jù)中提取文本信息以供對話框使用String title = itemData.get("news_title");String info = itemData.get("news_info");// 創(chuàng)建并顯示一個自定義對話框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=".MainActivity"android:exported="true"android:label="SimpleAdapterDemo">		<!--修改導(dǎo)航欄名稱--><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter>
</activity>

效果展示

http://aloenet.com.cn/news/28504.html

相關(guān)文章:

  • 手機網(wǎng)站制作代理公關(guān)公司排名
  • 廣州官網(wǎng)建設(shè)seo搜索優(yōu)化是什么意思
  • 知識付費網(wǎng)站開發(fā)教程百度搜索提交入口
  • 做網(wǎng)站鏈接容易嗎百度手機瀏覽器下載
  • 網(wǎng)頁設(shè)計心得體會報告怎么寫怎么理解搜索引擎優(yōu)化
  • 網(wǎng)站制作價格與售后視頻網(wǎng)站seo怎么做
  • 嘉興做網(wǎng)站建設(shè)的公司哪家好長沙的seo網(wǎng)絡(luò)公司
  • 新鄉(xiāng)專業(yè)做淘寶網(wǎng)站蘇州seo整站優(yōu)化
  • 網(wǎng)站開發(fā)學(xué)習(xí)網(wǎng)站網(wǎng)站頁面禁止訪問
  • 廣州短視頻制作公司seo網(wǎng)頁優(yōu)化服務(wù)
  • 網(wǎng)站ui設(shè)計要點百度平臺營銷
  • 上海市建設(shè)安裝協(xié)會網(wǎng)站如何在百度發(fā)布廣告信息
  • logo智能設(shè)計一鍵生成器無憂seo博客
  • 西安電腦網(wǎng)站建設(shè)aso推廣平臺
  • 對網(wǎng)站設(shè)計的建議網(wǎng)絡(luò)推廣渠道和方式
  • 懷化做網(wǎng)站的公司怎么做關(guān)鍵詞排名靠前
  • 模擬網(wǎng)站建設(shè)對網(wǎng)絡(luò)營銷的認(rèn)識
  • 網(wǎng)站url改版線下營銷方式主要有哪些
  • 做那種網(wǎng)站賺錢廣州代運營公司有哪些
  • 做視頻網(wǎng)站 視頻放在哪里西安網(wǎng)頁設(shè)計
  • 不準(zhǔn)別人網(wǎng)站做反鏈好網(wǎng)站制作公司
  • 織夢網(wǎng)站如何做地區(qū)分站青島seo整站優(yōu)化招商電話
  • 重慶網(wǎng)站建設(shè)哪個公司好百度關(guān)鍵詞搜索量
  • wordpress模板用法深圳百度網(wǎng)站排名優(yōu)化
  • h5如何做多頁面網(wǎng)站愛站查詢
  • 網(wǎng)頁設(shè)計技能證書怎么考寧波如何做抖音seo搜索優(yōu)化
  • 做網(wǎng)站需要學(xué)那幾個軟件whois查詢 站長工具
  • 蘭溪做網(wǎng)站seo優(yōu)化工作內(nèi)容做什么
  • 品牌宣傳型網(wǎng)站構(gòu)成營銷策劃與運營公司
  • 網(wǎng)站開發(fā)有沒有前途12345微信公眾號