`
guzizai2007
  • 浏览: 355360 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Layout1.6

 
阅读更多

ListView BaseAdapter:

package com.example.android_listview_activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

/**
 * @desc	自定义适配器
 * @author	ljt
 * @time	2014年8月27日 上午11:15:27
 */
public class MainActivity5 extends Activity{
	
	private static final String TAG = "MainActivity";
	
	private ListView listView;
	
	private int[] images = {R.drawable.abc_ic_go_search_api_holo_light,R.drawable.abc_ic_go_search_api_holo_light};
	
	private String[] names = {"北京","上海"};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		listView = (ListView)this.findViewById(R.id.listView1);
		MyAdapter adapter = new MyAdapter();
		listView.setAdapter(adapter);
	}
	
	/**
	 * @desc	自定义适配器
	 * @author	ljt
	 * @time	2014年8月27日 上午11:09:13
	 */
	class MyAdapter extends BaseAdapter{

		/**
		 * How many items are in the data set represented by this Adapter.
		 */
		@Override
		public int getCount() {
			return names.length;
		}

		/**
		 * Get the data item associated with the specified position in the data set.
		 */
		@Override
		public Object getItem(int position) {
			return names[position];
		}
		
		/**
		 * Get the row id associated with the specified position in the list.
		 */
		@Override
		public long getItemId(int position) {
			return position;
		}

		/**
		 * 创建列表项
		 */
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			Log.i(TAG, "position == "+position);
			
			// 将layout的xml布局文件实例化为View类对象
			View view = getLayoutInflater().inflate(R.layout.source2,null);
			ImageView imageView = (ImageView)view.findViewById(R.id.imageView3);
			imageView.setImageResource(images[position]);
			
			TextView textView = (TextView)view.findViewById(R.id.textView3);
			textView.setText(names[position]);
			
			return view;
		}
		
	}
	
}

 

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    PADS Layout四层板设置简明教程

    PADS Layout四层板设置简明教程.pdf

    DevExpress VCL v2012 vol 1.6源码、例子、帮助

    DevExpress VCL v2012 vol 1.6 Delphi VCL. 包含所有源码、例子、帮助 支持Metro啦! What's New in DevExpress VCL 12.1.6 Release Notes The following sections list all minor and major changes in ...

    DevExpress VCL 2012 vol 1.6源码、例子、帮助-Part2

    DevExpress VCL v2012 vol 1.6 Delphi VCL. 包含所有源码、例子、帮助 支持Metro啦! What's New in DevExpress VCL 12.1.6 Release Notes The following sections list all minor and major changes in ...

    DevExpress VCL 2012 vol 1.6源码、例子、帮助-Part1

    DevExpress VCL v2012 vol 1.6 Delphi VCL. 包含所有源码、例子、帮助 支持Metro啦! What's New in DevExpress VCL 12.1.6 Release Notes The following sections list all minor and major changes in ...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-part2

    DevExpress VCL v2012 vol 1.6 Delphi VCL. 包含所有源码、例子、帮助 支持Metro啦! What's New in DevExpress VCL 12.1.6 Release Notes The following sections list all minor and major changes in ...

    DevExpress VCL v2012 vol 1.6源码-例子-帮助-part2

    DevExpress VCL v2012 vol 1.6 包含所有源码、例子、帮助 如果你安装过其它版本的DevExpressVCL,安装前请完全卸载老版本的Dev控件,并执行“清理Dev残余文件”,清理System32下的DevExpress的BPL文件。 What's...

    DevExpress VCL v2012 vol 1.6源码-例子-帮助-part1

    DevExpress VCL v2012 vol 1.6 包含所有源码、例子、帮助 如果你安装过其它版本的DevExpressVCL,安装前请完全卸载老版本的Dev控件,并执行“清理Dev残余文件”,清理System32下的DevExpress的BPL文件。 What's...

    DevExpress VCL v2012 vol 1.6源码、例子、帮助-Part1

    DevExpress VCL v2012 vol 1.6 Delphi VCL. 包含所有源码、例子、帮助 支持Metro啦! What's New in DevExpress VCL 12.1.6 Release Notes The following sections list all minor and major changes in ...

    ComponentSet(试用版)1.6

    ComponentSet是一个Java swing 控件集,包括JWizardPane, JListView, Layout Suite(CellLayout, BoxLayout2, CardLayout2, GridLayout2), JDirChooser, JCalendar, JFontChooser, JLinkButton, JSidePane, JSideBar, ...

    cs-hud-observer:CS 1.6 流媒体叠加用于向观众广播特殊的 hud

    CS Hud Observer 是 CS 1.6 的流叠加,此流叠加背后的基本思想是向流观察者显示当前不存在的游戏状态。 主意 使用通过套接字 (TCP/UDP) 的游戏服务器流事件到将运行此软件的本地流媒体,该软件将向流观察者显示数据...

    jQuery EasyUI 1.3.6简体中文版(chm/exe).rar

    软件介绍: jQuery EasyUI 官方API文档中文版V1.3.6,压缩包内附EXE/CHM...内容包括:Base(基础)Layout(布局)Menu and Button(菜单和按钮)Form(表单)Windows(窗口)DataGrid and Tree(表格和树)Extension(扩展)

    Programming Windows Presentation Foundation (wpf编程英文文字版)

    Section 1.6. Data Binding Section 1.7. Dependency Properties Section 1.8. Resources Section 1.9. Styles and Control Templates Section 1.10. Graphics Section 1.11. Application Deployment ...

    SAP MM customizing

    1.6 ASSIGN PURCHASE ORGANIZATION TO PLANT 7 1.7 CREATE PURCHASE GROUP 8 2. BASIC SETUP 10 2.1 DEFINE SCREEN LAYOUT OF MATERIAL MASTER 10 2.2 DEFINE MATERIAL TYPE 11 2.3 SETUP MATERIAL NUMBER RANGE 13 ...

    LSSVMlab_v17_R2009b_R2010b.zip

    Because many readers are familiar with the layout of version 1.5 and version 1.6, we have tried to change it as little as possible. Here is a summary of the main changes: • The major difference with...

    基于Golang开发的棋牌游戏服务端demo(推筒子游戏)

    根据layout.json创建layout_dev.json,其中common_config与must服务不变,其他XX_server服务里面内容都放在新的all_server服务里面 因为本地测试需要将所有服务都同时启动,rancher上面根据环境变量运行服务 例如: ...

    Amiga2000-remake:使用Sprint Layout重新创建Amiga2000主板

    使用Sprint Layout重新创建Amiga2000主板 如果要构建此板,请使用Amiga2000rev6.2.incl.mods.1.8.5.zip中的gerber。 唯一没有应用的是r2-c1组合的占用空间,因为它涉及移动许多迹线,而且我不知道它对电路板的工作有...

    WiscKey - Separating Keys from Values.pdf

    key-value store with a performance-oriented data layout that separates keys from values to minimize I/O amplification. The design of WiscKey is highly SSD optimized, leveraging both the sequential and...

    Android代码-ExampleAndroid

    Q.what is this? A.This is my example for Android IS01. Q.What kind of example... ...GPS/ Map/Layout.. RecodeSound.. Q.What is android Version. A.It's Android1.6. Because IS01 is version 1.6.

    E4418CORE-V1C资料

    E4418CORE 基于三星和NEXELL 联合发布的四核COTEX-A9 CPU,主频最高为1.6GHz, 4418 集成了高性能GPU,具有2D 和3D 加速功能。 E4418CORE 内部集成1GB(M18 型)和2G(M2A 型)的DDR3 内存,支持DDR3-1600 内存, 总线...

    E4418CORE-V1C结构特性

    E4418CORE 基于三星和NEXELL 联合发布的四核COTEX-A9 CPU,主频最高为1.6GHz, 4418 集成了高性能GPU,具有2D 和3D 加速功能。 E4418CORE 内部集成1GB(M18 型)和2G(M2A 型)的DDR3 内存,支持DDR3-1600 内存, 总线...

Global site tag (gtag.js) - Google Analytics