机试

机试_第1张图片



机试_第2张图片



机试_第3张图片

package com.example.js; import android.app.Activity; import android.app.AlertDialog; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; public class Lieb extends Activity { ListView list_view1; String name[]={"冯路兵","身高:188cm","体重250kg"}; int icon[]={R.drawable.user,R.drawable.arrows}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lieb); list_view1=(ListView) findViewById(R.id.list_view1); myAdapter adapter = new myAdapter(); list_view1.setAdapter(adapter); list_view1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { // TODO Auto-generated method stub new AlertDialog.Builder(Lieb.this) .setTitle("警告").setMessage("您没有"+position+"删除权限!") .setPositiveButton("取消", null).show(); } }); } class myAdapter extends BaseAdapter{ @Override public int getCount() { // TODO Auto-generated method stub return 20; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub shuju huju=null; if(convertView==null){ convertView=View.inflate(Lieb.this, R.layout.lib_lieb, null); huju=new shuju(); 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]); return convertView; } } class shuju{ ImageView image1; TextView textView_shuju1; TextView textView_shuju2; TextView textView_shuju3; ImageView image2; } }

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.CheckBox; import android.widget.ImageView; public class MainActivity extends Activity { ImageView imageview; CheckBox checkbox; boolean checkboxif=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(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent(MainActivity.this,Lieb.class)); } }); checkbox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if(checkboxif){ checkbox.setButtonDrawable(R.drawable.checkbox_normal); checkboxif=false; }else{ checkbox.setButtonDrawable(R.drawable.checkbox_presed); checkboxif=true; } } }); } }

你可能感兴趣的:(机试)