• 20150625_Andriod_02_ListView2_多条目显示_选中


      android listview

      参考地址:

      http://www.cnblogs.com/zhengbeibei/archive/2013/05/14/3078805.html
      http://xys289187120.blog.51cto.com/3361352/657171/
      http://jeyechao.iteye.com/blog/1149127

    ************************************************************************

    package com.example.ht;

    import android.support.v7.app.ActionBarActivity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;

    //////////////////////////
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Map;

    import android.app.ListActivity;
    //import android.os.Bundle;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ListView;
    import android.widget.SimpleAdapter;
    import android.widget.Toast;
    import android.widget.AdapterView.OnItemClickListener;
    //////////////////////////

    //public class Fr_05_view_s2 extends ActionBarActivity {
    public class Fr_05_view_s2 extends ListActivity {
       
      // TitleList -------------
         //////////////////////////
      private String[] mListTitle = { "姓名", "性别", "年龄", "居住地","邮箱"}; 
      private String[] mListStr = { "云樵", "男", "35", "北京", 
             "wuhang@gmail.com" }; 
         ListView mListView = null; 
         ArrayList<Map<String,Object>> mData= new ArrayList<Map<String,Object>>();;
      //////////////////////////   
     
     @Override
     protected void onCreate(Bundle savedInstanceState) {
      //super.onCreate(savedInstanceState);
      //setContentView(R.layout.activity_fr_05_view_s2);
      
      
      mListView = getListView();
          
      int lengh = mListTitle.length;
      for(int i =0; i < lengh; i++) {
          Map<String,Object> item = new HashMap<String,Object>();
          item.put("title", mListTitle[i]);
          item.put("text", mListStr[i]);
          mData.add(item);
      }
      
      SimpleAdapter adapter = new SimpleAdapter(this,mData,android.R.layout.simple_list_item_2,
       new String[]{"title","text"},new int[]{android.R.id.text1,android.R.id.text2});
             setListAdapter(adapter);
            
             mListView.setOnItemClickListener(new OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> adapterView, View view, int position,
               long id) {
           Toast.makeText(Fr_05_view_s2.this,"您选择了标题:" + mListTitle[position] + "内容:"+mListStr[position], Toast.LENGTH_LONG).show();
              }
          });
            
             super.onCreate(savedInstanceState);
     }

     
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.fr_05_view_s2, menu);
      return true;
     }

     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
       return true;
      }
      return super.onOptionsItemSelected(item);
     }
     
     
    }

    ************************************************************************

  • 相关阅读:
    codeforces 589G G. Hiring(树状数组+二分)
    树状数组的小总结
    virtualenv
    Redis备份与恢复
    Linux 网站相关
    MySQL文章参考
    动态执行表不可访问,本会话的自动统计被禁止 。 在执行菜单里你可以禁止统计,或在v$session,v$sesstat 和 v$statname 表里获得select权限
    app已损坏,打不开。你应该将它移到废纸篓
    macos系统用virtualbox安装Linux系统无法设
    Hadoop 分布式部署HDFS-hadoop用户部署
  • 原文地址:https://www.cnblogs.com/hutie1980/p/4600434.html
Copyright © 2020-2023  润新知