当前位置: 编程技术>移动开发
本页文章导读:
▪Anroid之SimpleAdapter简略实例和SimpleAdapter参数说明 Anroid之SimpleAdapter简单实例和SimpleAdapter参数说明
SimpleAdapter基本上认知了其参数含义 用起来就简单多了
SimpleAdapter的参数说明
第一个参数 表示访问整个android应用程序接口,基本上所有的组.........
▪ 犀利的jquery之快速定位 锋利的jquery之快速定位 学习jquery有些时间了,感觉jquery的封装的特性特别出色,尤其是屏蔽了复杂的DOM操作,在以往的操作中,定位一个标记,总要想文档,树这些概念,但是在jquery中,只要和c.........
▪ 年薪百万不是梦 年薪百万不是梦!墨麟集团(http://www.mokylin.com/)上海浦东张江研发公司高薪诚聘端游手游服务器、客户端、引擎开发,薪酬待遇:15-25K,项目奖金超级诱人,有意者请小窗QQ 180943698,或直接.........
[1]Anroid之SimpleAdapter简略实例和SimpleAdapter参数说明
来源: 互联网 发布时间: 2014-02-18
Anroid之SimpleAdapter简单实例和SimpleAdapter参数说明
SimpleAdapter基本上认知了其参数含义 用起来就简单多了 SimpleAdapter的参数说明 第一个参数 表示访问整个android应用程序接口,基本上所有的组件都需要
第二个参数表示生成一个Map(String ,Object)列表选项
第三个参数表示界面布局的id 表示该文件作为列表项的组件
第四个参数表示该Map对象的哪些key对应value来生成列表项
第五个参数表示来填充的组件 Map对象key对应的资源一依次填充组件 顺序有对应关系
注意的是map对象可以key可以找不到 但组件的必须要有资源填充 因为 找不到key也会返回null 其实就相当于给了一个null资源
下面的程序中如果 new String[] { "name", "head", "desc","name" } new int[] {R.id.name,R.id.head,R.id.desc,R.id.head}
这个head的组件会被name资源覆盖
SimpleAdapter基本上认知了其参数含义 用起来就简单多了 SimpleAdapter的参数说明 第一个参数 表示访问整个android应用程序接口,基本上所有的组件都需要
第二个参数表示生成一个Map(String ,Object)列表选项
第三个参数表示界面布局的id 表示该文件作为列表项的组件
第四个参数表示该Map对象的哪些key对应value来生成列表项
第五个参数表示来填充的组件 Map对象key对应的资源一依次填充组件 顺序有对应关系
注意的是map对象可以key可以找不到 但组件的必须要有资源填充 因为 找不到key也会返回null 其实就相当于给了一个null资源
下面的程序中如果 new String[] { "name", "head", "desc","name" } new int[] {R.id.name,R.id.head,R.id.desc,R.id.head}
这个head的组件会被name资源覆盖
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity" >
<ListView
android:id="@+id/lt1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<?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" >
<ImageView
android:id="@+id/head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#f0f"
android:paddingLeft="10dp"/>
<TextView
android:id="@+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:paddingLeft="10dp"/>
</LinearLayout>
</LinearLayout>
package com.example.simpleadptertest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class MainActivity extends Activity {
private String[] name = { "剑萧舞蝶", "张三", "hello", "诗情画意" };
private String[] desc = { "魔域玩家", "百家执行", "高级的富一代", "妹子请过来..一个善于跑妹子的。。" };
private int[] imageids = { R.drawable.libai, R.drawable.nongyu,
R.drawable.qingzhao, R.drawable.tiger };
private ListView lt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Map<String, Object>> listems = new ArrayList<Map<String, Object>>();
for (int i = 0; i < name.length; i++) {
Map<String, Object> listem = new HashMap<String, Object>();
listem.put("head", imageids[i]);
listem.put("name", name[i]);
listem.put("desc", desc[i]);
listems.add(listem);
}
/*SimpleAdapter的参数说明
* 第一个参数 表示访问整个android应用程序接口,基本上所有的组件都需要
* 第二个参数表示生成一个Map(String ,Object)列表选项
* 第三个参数表示界面布局的id 表示该文件作为列表项的组件
* 第四个参数表示该Map对象的哪些key对应value来生成列表项
* 第五个参数表示来填充的组件 Map对象key对应的资源一依次填充组件 顺序有对应关系
* 注意的是map对象可以key可以找不到 但组件的必须要有资源填充 因为 找不到key也会返回null 其实就相当于给了一个null资源
* 下面的程序中如果 new String[] { "name", "head", "desc","name" } new int[] {R.id.name,R.id.head,R.id.desc,R.id.head}
* 这个head的组件会被name资源覆盖
* */
SimpleAdapter simplead = new SimpleAdapter(this, listems,
R.layout.simple_item, new String[] { "name", "head", "desc" },
new int[] {R.id.name,R.id.head,R.id.desc});
lt1=(ListView)findViewById(R.id.lt1);
lt1.setAdapter(simplead);
}
@Override
public 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;
}
}
[2] 犀利的jquery之快速定位
来源: 互联网 发布时间: 2014-02-18
锋利的jquery之快速定位
css定位的代码:
直接定位系统标签:
定位带有class的标签:
在jquery中定位这样的标签
直接定义系统标签及定义带有class属性的标签:
现在我们来看看用DOM找到一个标签:
学习jquery有些时间了,感觉jquery的封装的特性特别出色,尤其是屏蔽了复杂的DOM操作,在以往的操作中,定位一个标记,总要想文档,树这些概念,但是在jquery中,只要和css一样的写法,就可以快速定位一个标记.
下面我们通过代码来看看是怎么定位的:css定位的代码:
直接定位系统标签:
ul,li{
margin:0px;
padding:0px;
list-style:none;
}
.Loading{
width:400px;
/*margin-left:auto;
//margin-right:auto;*/
margin:0 auto;
visibility:hidden;
}
#contentsecond{
width:300px;
height:100px;
}
在jquery中定位这样的标签
$("#realcontent").load("test.html");
直接定义系统标签及定义带有class属性的标签:
$("div.contentin").removeClass("contentin");
现在我们来看看用DOM找到一个标签:
function setBorder( n )
{
document.getElementById( "image1" ).border = n;
}
(function() {
var
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
undefined,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$,
jQuery = window.jQuery = window.$ = function(selector, context) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init(selector, context);
},
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/;
jQuery.fn = jQuery.prototype = {
init: function(selector, context) {
// Make sure that a selection was provided
// Make sure that a selection was provided
selector = selector || document;
this[0] = selector;
this.length = 1;
this.context = selector;
return this;
},
show:function() {
alert("this.show");
},
// Start with an empty selector
selector: "",
// The current version of jQuery being used
jquery: "1.3.2"
};
jQuery.fn.init.prototype = jQuery.fn;
})();
function test(src){
alert($(src));
$(src).show();
通过对代码的简单理解,我们不难发现,jquery简单的背后做了大量的总结及抽象工作,所以我们可以这么总结:
1,要向写好代码,必须不断优化改进!
2,要向做好软件,尽量灵活抽象是正道
3,一个团队的管理,犹如设计一个页面,快速定位某项工作的基础是有一个全局的管理观念(参考代码中的window)
[3] 年薪百万不是梦
来源: 互联网 发布时间: 2014-02-18
年薪百万不是梦!
墨麟集团(http://www.mokylin.com/)上海浦东张江研发公司高薪诚聘端游手游服务器、客户端、引擎开发,薪酬待遇:15-25K,项目奖金超级诱人,有意者请小窗QQ 180943698,或直接发简历至 hr@mokun.net。
想买房吗?想跟你心仪的女孩结婚吗?那就来墨麟集团吧!年薪百万不是梦!
墨麟集团(http://www.mokylin.com/)上海浦东张江研发公司高薪诚聘端游手游服务器、客户端、引擎开发,薪酬待遇:15-25K,项目奖金超级诱人,有意者请小窗QQ 180943698,或直接发简历至 hr@mokun.net。
想买房吗?想跟你心仪的女孩结婚吗?那就来墨麟集团吧!年薪百万不是梦!
最新技术文章: