设为首页 加入收藏

TOP

Android使用SimpleAdapter实现TextView按钮
2014-11-24 03:03:22 来源: 作者: 【 】 浏览:2
Tags:Android 使用 SimpleAdapter 实现 TextView 按钮

Android做点东西的确是很麻烦,这是我实际做的一个例子,希望能够很好的让大家理解。


我想很多人到看到过这样的界面吧?很基础的一个界面,但对于初学者却很难把它做出来。我下面演示一下自己做的代码,但太细的细节就不讲了,讲起来太麻烦了。


在此代码中,使用的layout中的xml文件为main.xml,其内容为:


< xml version="1.0" encoding="utf-8" >
android:id="@+id/text_ZipUnZip"
android:layout_width="fill_parent"
android:layout_height=" android:attr/listPreferredItemHeight"
android:textAppearance=" android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:singleLine="true"
/>


代码为:


public class EagleZip extends ListActivity {
//private static final String[] tPROJECTION = new String[] {"Zip","UnZip"};


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);

getListView().setOnCreateContextMenuListener(this);


String[] tString=new String[]{"key",};
int[] tInt=new int[]{R.id.text_ZipUnZip};
Map tMap;

tMap=new HashMap();
List> tList=new ArrayList>();
tMap.put("key","Zip");
tList.add(tMap);

tMap=new HashMap();
tMap.put("key", "UnZip");
tList.add(tMap);

SimpleAdapter tAdapter = new SimpleAdapter(this, tList,R.layout.main, tString,tInt);
setListAdapter(tAdapter);
getListView().setTextFilterEnabled(true);
}
}


当然,大家要有java的基础,否则看懂也不是很容易.加油学习吧!呵呵。。。。。。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android有趣的全透明效果 下一篇Android源码下载流程挑错(Ubuntu..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Announcing October (2025-12-24 15:18:16)
·MySQL有什么推荐的学 (2025-12-24 15:18:13)
·到底应该用MySQL还是 (2025-12-24 15:18:11)
·进入Linux世界大门的 (2025-12-24 14:51:47)
·Download Linux | Li (2025-12-24 14:51:44)