1.修改该项目gen文件夹下package的包名 refactor/rename/新的包名
2.修改该项目manifest.xml package="新的包名"
3.第一步 第二步 的新的包名 要一致 ,这样就ok了,顺序不要颠倒
ListView嵌套CheckBox (解决滑动时重复选择的问题)
adapter中做处理:
package com.chenglang.adapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.chenglang.bean.MytxtBean;
import com.chenglang.work.MytxtActivity;
import com.chenglang.work.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
public class Mytxtl_list_adapter extends BaseAdapter {
Context context;
List<MytxtBean> list = new ArrayList<MytxtBean>();
public Mytxtl_list_adapter(Context context, List<MytxtBean> list) {
// TODO Auto-generated constructor stub
this.context = context;
this.list = list;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return list.get(arg0);
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return arg0;
}
Gridholder gridholder = new Gridholder();
@Override
public View getView( final int arg0, View arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
if (arg1 == null) {
arg1 = LayoutInflater.from(context).inflate(
R.layout.mytext_list_item_view, null);
arg1.setTag(gridholder);
} else {
gridholder = (Gridholder) arg1.getTag();
}
gridholder.cb = (CheckBox) arg1.findViewById(R.id.cb);
gridholder.cbtv = (TextView) arg1.findViewById(R.id.cbtv);
gridholder.dingao = (TextView) arg1.findViewById(R.id.daidinggao);
gridholder.person = (TextView) arg1.findViewById(R.id.person);
gridholder.leixin = (TextView) arg1.findViewById(R.id.putong);
gridholder.time = (TextView) arg1.findViewById(R.id.time);
MytxtBean bean = list.get(arg0);
gridholder.cbtv.setText(bean.getCbdata());
gridholder.dingao.setText(bean.getDingaodata());
gridholder.leixin.setText(bean.getLeixingdata());
gridholder.person.setText(bean.getPersondata());
gridholder.time.setText(bean.getTimedata());
if(MytxtActivity.checkPos.get(arg0)){
gridholder.cb.setChecked(true);
}else{
gridholder.cb.setChecked(false);
}
return arg1;
}
public static class Gridholder {
TextView dingao, leixin, person, time,cbtv;
public CheckBox cb;
}
}
在主代码中:
package com.chenglang.work;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.chenglang.adapter.Mytxtl_list_adapter;
import com.chenglang.adapter.Mytxtl_list_adapter.Gridholder;
import com.chenglang.bean.MytxtBean;
import com.chenglang.resource.MytxtData;
import android.animation.ArgbEvaluator;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MytxtActivity extends Activity implements OnClickListener,
OnItemClickListener {
ListView mytextlist;
List<MytxtBean> datalistm = new ArrayList<MytxtBean>();
MytxtBean bean;
ImageButton backbtn;
Mytxtl_list_adapter myadapter;
TextView caogaotv,searchtv;
public static Map<Integer, Boolean> checkPos;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mytext_view);
init();
}
private void init() {
// TODO Auto-generated method stub
caogaotv = (TextView) findViewById(R.id.caogaotv);
searchtv = (TextView) findViewById(R.id.searchtv);
mytextlist = (ListView) findViewById(R.id.mytext_list);
setlistdata();
backbtn = (ImageButton) findViewById(R.id.mytextback);
backbtn.setOnClickListener(this);
caogaotv.setOnClickListener(this);
searchtv.setOnClickListener(this);
checkPos = new HashMap<Integer, Boolean>();
for (int i = 0; i < datalistm.size(); i++) {
checkPos.put(i, false);
}
}
private void setlistdata() {
for (int i = 9; i < 15; i++) {
bean = new MytxtBean(MytxtData.CBDATA[0], MytxtData.DINGGAODATA[0],
MytxtData.LEIXINGDATA[0], MytxtData.PERSON[0],
MytxtData.TIME[0]);
datalistm.add(bean);
}
myadapter = new Mytxtl_list_adapter(MytxtActivity.this, datalistm);
mytextlist.setAdapter(myadapter);
mytextlist.setItemsCanFocus(true);
mytextlist.setOnItemClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch (arg0.getId()) {
case R.id.mytextback:
Intent intent = new Intent(MytxtActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
case R.id.caogaotv:
case R.id.searchtv:
Toast.makeText(MytxtActivity.this, "没有提供界面", Toast.LENGTH_SHORT).show();
break;
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
System.out.println("第"+arg2+"项");
new AlertDialog.Builder(this).setIcon(R.drawable.ic_about)
.setTitle("hello:")
.setMessage(datalistm.get(arg2).getCbdata())
.setNegativeButton("退出", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
}).show();
}
}
越努力.越幸福.----willingseal.
(1)可以下载多个版本的xcode,在mac上安装,选择保留两者。
(2)你的xcode是在app store 下载安装的。( 我之前是直接用别人发给我的xcode4.6在mac上安装的,然后在app stroe上升级成xcode5,mac上就只有一个xcode了。要使用以前写的代码,在xcode5上很多问题,特别是你下载别人的代码要去看的时候,就想用一个低版本的xcode去打开。)
a. 你需要到应用程序里面新建一个文件夹,把xcode5拖入文件夹里面。
b.去google下载你需要的xcode版本,在mac上安装。