packagecom.example.beicai;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.os.Bundle;
importandroid.view.Menu;
importandroid.view.MenuItem;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.widget.CheckBox;importandroid.widget.ImageView;
//定义了一些布局,登录页面的跳转
publicclassMainActivityextendsActivity{
ImageView imageview;
CheckBox checkbox;
booleancheckboxif=true;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
checkbox=(CheckBox) findViewById(R.id.checkbox);
imageview=(ImageView) findViewById(R.id.imageview); imageview.setOnClickListener(newOnClickListener() {
@Override
publicvoidonClick(View v){
// TODO Auto-generated method
stubstartActivity(newIntent(MainActivity.this,ContentActivity.class));
}
});
checkbox.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View v){
// TODO Auto-generated method
stubif(checkboxif){
checkbox.setButtonDrawable(R.drawable.checkbox_normal);
checkboxif=false;
}else{
checkbox.setButtonDrawable(R.drawable.checkbox_presed);
checkboxif=true;
}
}
});
}
packagecom.example.beicai;
importandroid.app.Activity;
importandroid.app.AlertDialog;
importandroid.content.DialogInterface;
importandroid.content.DialogInterface.OnClickListener;
importandroid.graphics.drawable.Drawable;importandroid.os.Bundle;
importandroid.view.Menu;
importandroid.view.MenuItem;
importandroid.view.View;
importandroid.view.ViewGroup;
importandroid.widget.AdapterView;
importandroid.widget.AdapterView.OnItemClickListener;
importandroid.widget.BaseAdapter;
importandroid.widget.ImageView;
importandroid.widget.ListView;
importandroid.widget.TextView;
public class ContentActivityextendsActivity{
ListView list_view1;
String name[]={"张三","身高:188cm","体重200kg"};
inticon[]={R.drawable.user,R.drawable.arrows};
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content);
list_view1=(ListView) findViewById(R.id.list_view1);
myAdapter adapter =newmyAdapter();
list_view1.setAdapter(adapter);
list_view1.setOnItemClickListener(newOnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View view,intposition,longid){
// TODO Auto-generated method
stubnewAlertDialog.Builder(ContentActivity.this) .setTitle("警告").setMessage("您没有"+position+"删除权限!") .setPositiveButton("取消",null).show();
}
});
}
class myAdapter extends BaseAdapter{
@Override
publicintgetCount(){// TODO Auto-generated method stubreturn20;
}
@Override
publicObjectgetItem(intposition){// TODO Auto-generated method stubreturnposition;
}
@Override
publiclonggetItemId(intposition){
// TODO Auto-generated method stubreturnposition;
}
@Override
public ViewgetView(intposition, View convertView, ViewGroup parent){
// TODO Auto-generated method
stubshuju huju=null;
if(convertView==null){
convertView=View.inflate(ContentActivity.this, R.layout.hsujukongjain,null);
huju=newshuju();
huju.image1=(ImageView) convertView.findViewById(R.id.image1);
huju.textView_shuju1=(TextView) convertView.findViewById(R.id.textView_shuju1); huju.textView_shuju2=(TextView) convertView.findViewById(R.id.textView_shuju2); huju.textView_shuju3=(TextView) convertView.findViewById(R.id.textView_shuju3);
huju.image2=(ImageView) convertView.findViewById(R.id.image2);
convertView.setTag(huju);
}else{
huju = (shuju) convertView.getTag();
}
huju.image1.setImageResource(icon[0]);
huju.textView_shuju1.setText(name[0]);
huju.textView_shuju2.setText(name[1]);
huju.textView_shuju3.setText(name[2]);
huju.image2.setImageResource(icon[1]);
returnconvertView;
}
}
classshuju{
ImageView image1;
TextView textView_shuju1;
TextView textView_shuju2;
TextView textView_shuju3;
ImageView image2;
}
}