androidlist,androidlistview复选框的高度
android 怎么取list数据
按以下代码可获取到list数据:
成都创新互联公司是一家集网站建设,贡嘎企业网站建设,贡嘎品牌网站建设,网站定制,贡嘎网站建设报价,网络营销,网络优化,贡嘎网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
package com.example.sdtg.sdsw;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class ListActivity extends Activity {
// 命名空间
// String nameSpace = "";
// 调用的方法名称
// String methodName = "GetSjSearch";
// EndPoint
// String endPoint = "";
// SOAP Action
// String soapAction = "";
// ListMapString, Object mList;
ListView ListV;
HashMapString, Object map = new HashMapString, Object();
private ListMapString,String listItems;
SimpleAdapter mListAdapter;
String name="";
String addr="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
listItems = new ArrayListMapString,String();
ListV=(ListView)findViewById(R.id.ListView01);
Handler indicate = new Handler();
//获取主页面传的值
final Intent data = getIntent();
name=data.getStringExtra("Name");
addr=data.getStringExtra("Addr");
new NetAsyncTask().execute();
ListV.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView? arg0, View arg1, int arg2,
long arg3) {
//获得选中项的HashMap对象
TextView viewtmc = (TextView) arg1.findViewById(R.id.textListmc);
TextView viewdz = (TextView) arg1.findViewById(R.id.textlistdz);
TextView viewid = (TextView) arg1.findViewById(R.id.textlistid);
//String playerChanged = c.getText().toString();
Bundle bundle = new Bundle();
bundle.putString("Name", viewtmc.getText().toString());
bundle.putString("Addr", viewdz.getText().toString());
bundle.putString("ID", viewid.getText().toString());
final Intent data = getIntent();
data.putExtras(bundle);
//跳转回MainActivity
//注意下面的RESULT_OK常量要与回传接收的Activity中onActivityResult()方法一致
ListActivity.this.setResult(RESULT_OK, data);
//关闭当前activity
ListActivity.this.finish();
}
});
};
class NetAsyncTask extends AsyncTaskObject, Object, String {
@Override
protected void onPostExecute(String result) {
if (result.equals("success")) {
mListAdapter = null;
mListAdapter = new SimpleAdapter(ListActivity.this, listItems, R.layout.item,new String[]{"title", "info", "img"}, new int[]{R.id.textListmc, R.id.textlistdz, R.id.textlistid});
ListV.setAdapter(mListAdapter);
}
super.onPostExecute(result);
}
@Override
protected String doInBackground(Object... params) {
// 命名空间
String nameSpace = "";
// 调用的方法名称
String methodName = "GetSjSearch";
// EndPoint
String endPoint = "";
// SOAP Action
String soapAction = "";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
// 设置需调用WebService接口需要传入的两个参数mobileCode、userId
rpc.addProperty("name", name);
rpc.addProperty("address", addr);
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
// SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的WebService
envelope.dotNet = true;
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
// 调用WebService
transport.call(soapAction, envelope);
} catch (Exception e) {
e.printStackTrace();
}
SoapObject object;
// 开始调用远程方法
try {
object = (SoapObject) envelope.getResponse();
int count = object.getPropertyCount();
// 得到服务器传回的数据
int count1 = object.getPropertyCount();
if(count10)
{
for (int i = 0; i count1; i++) {
MapString,String listItem = new HashMapString, String();
SoapObject soapProvince = (SoapObject)object.getProperty(i);
listItem.put("title", soapProvince.getProperty("DJXX_NSRMC").toString());
listItem.put("info", soapProvince.getProperty("DJXX_ZCDJ").toString());
//listItem.put("img", soapProvince.getProperty("DJXX_NSRSBH").toString());
listItems.add(listItem);
}}
} catch (IOException e) {
e.printStackTrace();
//return "IOException";
}
return "success";
}
}
}
android怎么取出list里面特定的数据
只需要循环一下,判断即可。
示例代码:
1.遍历整个list集合
for(int i=0; ilist.size(); i++){
}
2.在for循环中增加判断代码
if(list.get(i).equals("指定")){}
3.得到每一个item进行判断即可。
android怎么传一个list集合
方法1: 直接让User类继承Serializable或者Parcelable接口即可,Intent只可以传输序列化的对象pre t="code" l="java"//User类
public class User implements Serializable{
private String name;
.
}
//直接加入intent
ListUser list = new ArrayListUser();
Intent intent = new Intent();
intent.putExtra("list",list);
方法2: 把list集合转为字符串表示,可以使用json格式,直接用Gson框架转换即可,再到另一个activity转换回来pre t="code" l="java"ListUser list = new ArrayListUser();
Type type = new TypeTokenArrayListUser()(){}.getType();
String json = new Gson().toJson(list,type);
intent.putExtra("list",json);
//转换回ListUser
String json = getIntent.getStringExtra("list");
Type type = new TypeTokenArrayListUser()(){}.getType();
ListUser list = new Gson().fromJson(json,type);
网页名称:androidlist,androidlistview复选框的高度
网站地址:http://myzitong.com/article/dsdpids.html