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.text.method.ScrollingMovementMethod;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import java.io.IOException;

import org.ksoap2.SoapEnvelope; 
import org.ksoap2.serialization.SoapObject; 
import org.ksoap2.serialization.SoapSerializationEnvelope; 
import org.ksoap2.transport.HttpTransportSE; 
import org.xmlpull.v1.XmlPullParserException;

//import android.os.Bundle; 
import android.os.Handler; 
import android.os.Looper; 
import android.os.Message; 
import android.os.StrictMode; 
import android.app.Activity; 
//import android.view.Menu; 
//import android.view.View; 
//import android.view.View.OnClickListener; 
//import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView;

import java.util.HashMap;

public class F9_GridView extends ActionBarActivity {
 
    private EditText et_phone; 
    private TextView tv_result; 
    private Button btn_query;
   
    private String str_1, str_2;

@Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_f9_grid_view);
  
  
  initView();
  tv_result.setMovementMethod(ScrollingMovementMethod.getInstance());
 }
 
 ///////////////////////////
 private void initView() { 
        tv_result = (TextView) findViewById(R.id.tvResult); 
        et_phone = (EditText) findViewById(R.id.editText_f9_number); 
        btn_query = (Button) findViewById(R.id.btn_c2); 
        btn_query.setOnClickListener(new OnClickListener() { 
 
            @Override 
            public void onClick(View v) { 
                // TODO Auto-generated method stub 
                String phone = et_phone.getText().toString().trim(); 
                //if ("".equals(phone) || phone.length() < 7) { 
                if ("".equals(phone)) { 
                    et_phone.setText("您输入为空"); 
                    et_phone.requestFocus(); 
                    tv_result.setText(""); 
                    return; 
                } 
                getRemoteInfo(phone); 
            } 
        });
       
       
    } 
 
    /**
     * 查询号码段归属地的方法
     * 
     * @param phone
     *            手机号码段
     */ 
    public void getRemoteInfo(final String phone) { 
        new Thread(new Runnable() { 
             
            @Override 
            public void run() { 
                // TODO Auto-generated method stub 
                // 命名空间 
                String nameSpace = "http://tempuri.org/"; 
                // 调用方法的名称 
                String methodName = "selectAllCargoInfor"; 
                // EndPoint 
                String endPoint = "http://192.168.1.91:8028/an_sql_test1.asmx"; 
                // SOAP Action 
                String soapAction = "http://192.168.1.91:8028/an_sql_test1.asmx/selectAllCargoInfor"; 
                // 指定WebService的命名空间和调用方法 
                SoapObject soapObject = new SoapObject(nameSpace, methodName); 
                // 设置需要调用WebService接口的两个参数mobileCode UserId 
                //soapObject.addProperty("mobileCode", phone); 
                //soapObject.addProperty("userId", "");
                soapObject.addProperty("Ts_01", ""); 
                soapObject.addProperty("Ts_02", "");
                soapObject.addProperty("Ts_03", "");
                soapObject.addProperty("Ts_06", "");
                // 生成调用WebService方法调用的soap信息,并且指定Soap版本 
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( 
                        SoapEnvelope.VER12); 
                envelope.bodyOut = soapObject; 
                // 是否调用DotNet开发的WebService 
                envelope.dotNet = true; 
                envelope.setOutputSoapObject(soapObject); 
                HttpTransportSE transport = new HttpTransportSE(endPoint); 
                try { 
                    transport.call(soapAction, envelope); 
                //} catch (IOException e) {
                } catch (Exception e) {
                    // TODO Auto-generated catch block 
                    e.printStackTrace(); 
                }
               
                //catch (XmlPullParserException e) { 
                    // TODO Auto-generated catch block 
                    //e.printStackTrace(); 
                //} 
               
               
               
                /*
                // 获取返回的数据 
                SoapObject object = (SoapObject) envelope.bodyIn; 
                // 获取返回的结果

String result = object.getProperty(0).toString(); 
                Message message = handler.obtainMessage(); 
                message.obj = result; 
                handler.sendMessage(message);
                */
               
               
               
                /*
                SoapObject object = (SoapObject) envelope.getResponse();
                //如果获取的是个集合,就对它进行下面的操作
                if(object.getName()=="anyType")
                {
                 //遍历Web Service获得的集合
                for(int i=0;i<object.getPropertyCount();i++){
                
                 //MFirst m =new MFirst();
              
                 //获取单条的数据
                 SoapObject soapChilds =(SoapObject)soapObject.getProperty(i);
                
                 //对单个的数据进行再次遍历,把它的每行数据读取出来
                 for(int k=0;k<soapChilds.getPropertyCount();k++)
                 {
                 PropertyInfo propertyInfo = new PropertyInfo();
                 soapChilds.getPropertyInfo(k, propertyInfo);
                //获取实体类的所有属性
                 Field[] field = m.getClass().getDeclaredFields(); 
                //遍历所有属性
                     for(int j=0 ; j<field.length ; j++){    
                    //获取属性的名字
                            String name = field[j].getName();   
                */
               
               
                /*
                SoapObject result2 = (SoapObject) envelope.getResponse();
                result2 = (SoapObject)result2.getProperty(1);
                result2 = (SoapObject)result2.getProperty(0);
                for(int i=0;  i< result2.getPropertyCount(); i++ ){
                HashMap<String, String> map=new HashMap<String, String>();
                SoapObject soap = (SoapObject) result2.getProperty(i);
                String Ts_01 =soap.getProperty("Ts_01").toString();
                String Ts_02 =soap.getProperty("Ts_02").toString();
                String Ts_03 =soap.getProperty("Ts_03").toString();
                String Ts_06 =soap.getProperty("Ts_06").toString();
                }
               
                Message message = handler.obtainMessage(); 
                message.obj = result2; 
                handler.sendMessage(message);
                */
               
               
                // 获取返回的数据 
                SoapObject object = (SoapObject) envelope.bodyIn; 
                // 获取返回的结果

String result = object.getProperty(0).toString(); 
                Message message = handler.obtainMessage(); 
                message.obj = result; 
                handler.sendMessage(message);
               
                /////////
            } 
        }).start(); 
    } 
    private Handler handler = new Handler(){ 
        public void handleMessage(android.os.Message msg) { 
            // 将WebService得到的结果返回给TextView
            //tv_result.setText(msg.obj.toString()); 
         
         str_1 = msg.obj.toString();
         str_2 = str_1.replace("anyType{","");
         str_1 = str_2.replace("}","");
         str_2 = str_1.replace("string=","");
         //str_1 = str_2.replace(";","\r\n");
         str_1 = str_2.replace(";",",");
         tv_result.setText(str_1);
         
         /////////------/////////
         Intent intent = new Intent(F9_GridView.this,Fr_02_view_s1.class);
            Bundle bundle = new Bundle(); //通过Bundle实现数据的传递:
            bundle.putString("key_view_s1", str_1.toString());
            //bundle.putString("key_view_s1", "2");
            intent.putExtras(bundle);
            startActivity(intent);  
            /////////------/////////
        }; 
    };
 ///////////////////////////

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.f9__grid_view, 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);
 }
}

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

package com.example.ht;

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

//////////////////////////////////
import android.app.ListActivity;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.os.Bundle;
//////////////////////////////////

public class Fr_02_view_s1 extends ActionBarActivity {
    //////////////////////////////////
 private ListView mListView = null;
 private ArrayAdapter myAdapter = null;
 
 private String str_1;
    //////////////////////////////////
 
 private  static String[] db_string=null;
 private  static final String[] COUNTRIES=new String[]{"中国","俄罗斯","英国","法国","中国","俄罗斯","英国","法国"};
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_fr_02_view_s1);
  
        /////////------/////////
  Bundle bunde = this.getIntent().getExtras();
  str_1 = bunde.getString("key_view_s1").toString();
  db_string =str_1.split(",");
        /////////------/////////
  
  //setContentView(R.layout.main); 
        //设置一个Adapter 
  mListView = (ListView) findViewById(R.id.listView1);//得到ListView对象的引用 /*为ListView设置Adapter来绑定数据*/

// mListView.setAdapter(new ArrayAdapter<String>(this,
   //               android.R.layout.simple_expandable_list_item_1, COUNTRIES));
  
  mListView.setAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_expandable_list_item_1, db_string));

}
 
 @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_02_view_s1, 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);
 }

}

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

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ht.Fr_02_view_s1" >

<TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="listview1" />

<ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="50dp" >
    </ListView>

</RelativeLayout>

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

20150625_Andriod_01_ListView1_条目显示的更多相关文章

  1. iOS:类似于网易云音乐的刷新条目显示弹框

    一.介绍 在app中使用刷新控件或者第三方刷新库是最常见的功能,在请求服务器时,获取数据的过程是处于不可见状态的,那么通过这个刷新状态可以给用户以直观的感受,这是增强用户体验的一个相当好的方法.我个人 ...

  2. 20150625_Andriod_01_ListView1_条目选中

    android listview 参考地址: http://www.cnblogs.com/zhengbeibei/archive/2013/05/14/3078805.html  http://xy ...

  3. 20150625_Andriod_02_ListView2_多条目显示_选中

    android listview 参考地址: http://www.cnblogs.com/zhengbeibei/archive/2013/05/14/3078805.html  http://xy ...

  4. 【Android Developers Training】 101. 显示快速联系人挂件(Quick Contact Badge)

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  5. 我的Android进阶之旅------>Android Listview跳到指定条目位置的两种实现方法

    前言 今天实现ListView跳转到第一个条目位置时,使用smoothScrollToPosition(int position)方法跳转实现了,但是交互说不需要这样的动画效果,需要直接跳转到第一项, ...

  6. 把数据库内容显示在listview上

    数据库操作很简单,但用户想看见的是数据库里的内容,那么让数据库内容显示在屏幕上呢,下面做个简单演示,百变不离其中,先看步骤: 把数据库的数据显示至屏幕1. 任意插入一些数据 定义Javabean:Pe ...

  7. w - 显示已经登录的用户以及他们在做什么

    总览 (SYNOPSIS) w - [husfV] [user] 描述 (DESCRIPTION) w 显示 系统中 当前用户 的 信息, 以及 他们 的 进程. 第一行 中 依次 显示 当前时间, ...

  8. 学习日记-从爬虫到接口到APP

    最近都在复习J2E,多学习一些东西肯定是好的,而且现在移动开发工作都不好找了,有工作就推荐一下小弟呗,广州佛山地区,谢谢了. 这篇博客要做的效果很简单,就是把我博客的第一页每个条目显示在APP上,条目 ...

  9. 利用SimpleExpandableListAdapter为ExpandableListActivity提供数据

    首先MainActivity继承自ExpandableListActivity,其中的声明如下: setContentView(R.layout.expandmain); //定义一个:List,该L ...

随机推荐

  1. Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file

    springframework.version  3.2.6.RELEASE jdk 1.8

  2. Lintcode: Majority Number III

    Given an array of integers and a number k, the majority number is the number that occurs more than 1 ...

  3. 转:python socket编程详细介绍

    Python 提供了两个基本的 socket 模块. 第一个是 Socket,它提供了标准的 BSD Sockets API. 第二个是 SocketServer, 它提供了服务器中心类,可以简化网络 ...

  4. [原创]java WEB学习笔记48:其他的Servlet 监听器:域对象中属性的变更的事件监听器 (3 个),感知 Session 绑定的事件监听器(2个)

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  5. linux第12天 线程

    今天主要学习了共享内存,信号量的封装,还有线程. POSIX线程库 与线程有关的函数构成了一个完整的系列,绝大多数函数的名字都是以“pthread_”打头的 要使用这些函数库,要通过引入头文<p ...

  6. cocos2d对动画的各种操作

    瞬时动作:瞬时动作的基类是InstantAction 1.放置位置   CGPoint p = ccp(width,height); [sprite runAction:[CCPlace action ...

  7. ligerui+json_002_Grid用法、属性总结

    原文更全面,地址: http://blog.csdn.net/dxnn520/article/details/8216560 // ================================== ...

  8. JSon_零基础_005_将po(bean)对象集合List转换为JSon格式的对象字符串,返回给界面

    将po(bean)对象集合List转换为JSon格式的对象字符串,返回给界面 导入jar包: 编写:po(bean)代码: package com.west.webcourse.po; /** * 第 ...

  9. cmd进入某个目录

    love you my pig java枚举类 cmd进入某个目录 2011-04-06 15:49:38| 分类: 小知识 | 标签: |字号大中小 订阅     1.开始->运行->C ...

  10. paper 29 :CV会议+领先研究室+专家+代码网址

    做机器视觉和图像处理方面的研究工作,最重要的两个问题:其一是要把握住国际上最前沿的内容:其二是所作工作要具备很高的实用背景.解决第一个问题的办法就是找出这个方向公认最高成就的几个超级专家(看看他们都在 ...