package com.jqyd.manager; import java.util.ArrayList; import java.util.HashMap; import com.jqyd.adapter.MyAdapter; import com.jqyd.app.MyApp; import com.jqyd.app.ShareMethod; import com.jqyd.model.CustomerModule; import com.jqyd.shareInterface.Optdb_interfce; import com.jqyd.shareInterface.Optsharepre_interface; import com.jqyd.son.Khlb; import com.jqyd.son.Scjc; import com.jqyd.son.VisCust; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.Button; import android.widget.ListView; import android.widget.AdapterView.OnItemClickListener; public class Khcjlb extends Activity implements OnClickListener { private Button xzkh; private Button back; private MyAdapter adapter; private MyApp myApp; private ListView listView; private ArrayList<Bundle> listBundle = null; private HashMap<String,String> map = null; private ArrayList<HashMap<String, String>> listInfo = new ArrayList<HashMap<String, String>>(); private Optdb_interfce db ; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.khcjlb); listView = (ListView) this.findViewById(R.id.list); xzkh = (Button) this.findViewById(R.id.xzkh); back = (Button) this.findViewById(R.id.back); xzkh.setOnClickListener(this); back.setOnClickListener(this); myApp = (MyApp) this.getApplication(); init(); loadInfo(); } public void init(){ db = new Optdb_interfce(Khcjlb.this); listBundle = new ArrayList<Bundle>(); Bundle bundle = null; ArrayList<CustomerModule> customers = new ArrayList<CustomerModule>(); customers = db.searchCustomers(1,0,""); for(int i=0;i<customers.size();i++){ CustomerModule cust = (CustomerModule) customers.get(i); map = new HashMap<String, String>(); map.put("imageId", R.drawable.icon+""); map.put("textView1", cust.getShort_name()); map.put("textView2", cust.getAddress()); listInfo.add(map); bundle = new Bundle(); bundle.putString("cid", cust.getCid()); bundle.putString("cname", cust.getShort_name()); bundle.putString("linkman", cust.getLinkman()); bundle.putString("link_sim", cust.getLink_sim()); bundle.putString("address", cust.getAddress()); bundle.putString("sjhm", cust.getSjhm()); listBundle.add(bundle); } db.close_SqlDb(); } /** * 初始化,加载信息 */ public void loadInfo() { adapter = new MyAdapter(listInfo,Khcjlb.this,-3); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub Bundle bundle = listBundle.get(position); Intent intent =new Intent(); intent.putExtras(bundle); intent.setClass(Khcjlb.this, Khcj.class); startActivity(intent); } }); } @Override public void onClick(View v) { // TODO Auto-generated method stub if(v == xzkh){ Optsharepre_interface share_obj = new Optsharepre_interface(Khcjlb.this); share_obj.editPres("istakephoto", "0"); startActivity(new Intent().setClass(this,Khcj.class)); }else if(v == back){ finish(); } } }