package com.xiaoke.accountsoft.activity;import java.util.List;import com.xiaoke.accountsoft.dao.InaccountDAO;import com.xiaoke.accountsoft.model.Tb_inaccount;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.ListView;import android.widget.TextView;import android.widget.AdapterView.OnItemClickListener;public class Inaccountinfo extends Activity {public static final String FLAG = "id";// 定义一个常量,用来作为请求码ListView lvinfo;// 创建ListView对象String strType = "";// 创建字符串,记录管理类型@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.inaccountinfo);// 设置布局文件lvinfo = (ListView) findViewById(R.id.lvinaccountinfo);// 获取布局文件中的ListView组件ShowInfo(R.id.btnininfo);// 调用自定义方法显示收入信息lvinfo.setOnItemClickListener(new OnItemClickListener()// 为ListView添加项单击事件{// 覆写onItemClick方法@Overridepublic void onItemClick(AdapterView<?> parent, View view,int position, long id) {String strInfo = String.valueOf(((TextView) view).getText());// 记录收入信息String strid = strInfo.substring(0, strInfo.indexOf('|'));// 从收入信息中截取收入编号Intent intent = new Intent(Inaccountinfo.this, InfoManage.class);// 创建Intent对象intent.putExtra(FLAG, new String[] { strid, strType });// 设置传递数据startActivity(intent);// 执行Intent操作}});}///onCreateprivate void ShowInfo(int intType) {// 用来根据传入的管理类型,显示相应的信息String[] strInfos = null;// 定义字符串数组,用来存储收入信息ArrayAdapter<String> arrayAdapter = null;// 创建ArrayAdapter对象strType = "btnininfo";// 为strType变量赋值InaccountDAO inaccountinfo = new InaccountDAO(Inaccountinfo.this);// 创建InaccountDAO对象// 获取所有收入信息,并存储到List泛型集合中List<Tb_inaccount> listinfos = inaccountinfo.getScrollData(0,(int) inaccountinfo.getCount());strInfos = new String[listinfos.size()];// 设置字符串数组的长度int m = 0;// 定义一个开始标识for (Tb_inaccount tb_inaccount : listinfos) {// 遍历List泛型集合// 将收入相关信息组合成一个字符串,存储到字符串数组的相应位置strInfos[m] = tb_inaccount.get_id() + "|" + tb_inaccount.getType()+ " " + String.valueOf(tb_inaccount.getMoney()) + "元     "+ tb_inaccount.getTime();m++;// 标识加1}// 使用字符串数组初始化ArrayAdapter对象arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, strInfos);lvinfo.setAdapter(arrayAdapter);// 为ListView列表设置数据源}@Overrideprotected void onRestart() {// TODO Auto-generated method stubsuper.onRestart();// 实现基类中的方法ShowInfo(R.id.btnininfo);// 显示收入信息}}

更多相关文章

  1. Android实现TextView字符串波浪式跳动
  2. Android的数据处理:使用annotation实现JSON字符串解析为java对象
  3. android 反转字符串
  4. Android 字符串格式化 千位符
  5. 【转】Android 字符串的加密和解密
  6. Android最简单的使用数组的适配器Adapter
  7. Android开发者收入仅相当于iOS应用24%(同样做移动开发,Android开发
  8. Android将drawable图像转化为二进制字节数组与逆转换

随机推荐

  1. Android开发~点击其它控件弹出软键盘
  2. android获取屏幕长宽,status bar高度,设置
  3. Android多媒体技术之博客收集
  4. Android(安卓)代码混淆
  5. Android(安卓)Activity的生命周期
  6. android EventBus3.1.1使用
  7. AbsListView android:smoothScrollbar
  8. android txt文件读写(读取资源文件,读取私
  9. android 根据uri获取真实路径
  10. Android(安卓)touch sound