DwadMainActivity
public class MainActivity extends Activity implements OnClickListener {
EditText e1;
EditText e2;
ImageView dl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1= (EditText) findViewById(R.id.EditText01);
e2=(EditText) findViewById(R.id.editText1);
dl=(ImageView) findViewById(R.id.imageView1);
dl.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId()==dl.getId()&&e1.getText().length()>0&&e2.getText().length()>0) {
startActivity(new Intent(MainActivity.this,DwadMainActivity.class));
}else if (v.getId()==dl.getId()&&e1.getText().length()>0) {
Toast.makeText(getApplicationContext(), "密码错误", 0).show();
}else{
Toast.makeText(getApplicationContext(), "请输入账号", 0).show();
}
}
}
DwadMainActivity
public class DwadMainActivity extends Activity implements OnItemLongClickListener {
ListView ls;
ArrayList<Sudent> date = new ArrayList<Sudent>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dwad_main);
ls=(ListView) findViewById(R.id.listView1);
ls.setAdapter( new MyAdapter());
date.add(new Sudent("张三","身高:188cm","体重:200kg"));
date.add(new Sudent("李四","身高:180cm","体重:100kg"));
date.add(new Sudent("王五","身高:148cm","体重:1400kg"));
date.add(new Sudent("马六","身高:188cm","体重:200kg"));
date.add(new Sudent("赵七","身高:178cm","体重:180kg"));
date.add(new Sudent("小明","身高:188cm","体重:148kg"));
date.add(new Sudent("大明","身高:188cm","体重:130kg"));
date.add(new Sudent("李四","身高:188cm","体重:150kg"));
date.add(new Sudent("王五","身高:188cm","体重:135kg"));
date.add(new Sudent("马六","身高:188cm","体重:145kg"));
date.add(new Sudent("张三","身高:188cm","体重:179kg"));
ls.setOnItemLongClickListener(this);
}
class MyAdapter extends BaseAdapter{
@Override
public int getCount() {
// TODO Auto-generated method stub
return date.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return date.get(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
if (convertView==null) {
convertView=View.inflate(getApplicationContext(), R.layout.nvgh, null);
}
Sudent sudent = date.get(position);
TextView t1=(TextView) convertView.findViewById(R.id.textView1);
TextView t2=(TextView) convertView.findViewById(R.id.textView2);
TextView t3=(TextView) convertView.findViewById(R.id.textView3);
t1.setText(sudent.getName());
t2.setText(sudent.getSg());
t3.setText(sudent.getTz());
return convertView;
}
}
AlertDialog create ;
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
final AlertDialog.Builder ad=new AlertDialog.Builder(this);
View inflate = View.inflate(getApplicationContext(), R.layout.tex, null);
LinearLayout qx = (LinearLayout) inflate.findViewById(R.id.qx);
qx.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
create.cancel();
}
});
ad.setView(inflate);
ad.setCancelable(false);
create = ad.create();
create.show();
return false;
}
}
Sudent:
public class Sudent {
String name;
String sg;
String tz;
public Sudent(){
}
public Sudent(String name, String sg, String tz) {
super();
this.name = name;
this.sg = sg;
this.tz = tz;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSg() {
return sg;
}
public void setSg(String sg) {
this.sg = sg;
}
public String getTz() {
return tz;
}
public void setTz(String tz) {
this.tz = tz;
}
}
activity_dwad_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="移动软件学院学员"
android:background="@drawable/top"
android:gravity="center"/>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:orientation="vertical"
android:layout_weight="1"
android:background="@drawable/bc"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:background="#eee685"
android:orientation="vertical" >
<EditText
android:id="@+id/EditText01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:background="#ffffff"
android:drawableLeft="@drawable/user"
android:layout_weight="1"
android:ems="10"
android:hint="请输入用户名"
android:textSize="15dp" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:drawableLeft="@drawable/pwd_lock"
android:background="#ffffff"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:hint="请输入密码"
android:textSize="15dp"
>
<requestFocus />
</EditText>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 记住密码"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_weight="3"
android:button="@drawable/drawanle"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_login_normal"
android:layout_gravity="top|center"
android:layout_weight="3"
android:layout_marginTop="25dp"/>
</LinearLayout>
</LinearLayout>
nvgh.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/user"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="张三"
android:gravity="center_vertical"
android:textSize="20dp"
android:textColor="#000000"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="身高 123"
android:textColor="#3000ff"
android:gravity="center_vertical"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#3000ff"
android:text="体重 321"
android:gravity="center_vertical"/>
</LinearLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/arrows"
android:layout_weight="1"/>
</LinearLayout>
tex.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:text="警告"
android:textSize="20dp"
android:layout_weight="1"
android:drawableLeft="@drawable/user"
android:textColor="#0090ff"/>
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#0090ff" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_weight="1.00"
android:text="你没有权限删除!"
android:gravity="center"
android:textColor="#000000"
android:textSize="17dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#999999"/>
<LinearLayout
android:id="@+id/qx"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="0.23"
android:gravity="center"
android:text="取消"
android:textColor="#000000"
android:textSize="13dp" />
</LinearLayout>
</LinearLayout>
public class MainActivity extends Activity implements OnClickListener {
EditText e1;
EditText e2;
ImageView dl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1= (EditText) findViewById(R.id.EditText01);
e2=(EditText) findViewById(R.id.editText1);
dl=(ImageView) findViewById(R.id.imageView1);
dl.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId()==dl.getId()&&e1.getText().length()>0&&e2.getText().length()>0) {
startActivity(new Intent(MainActivity.this,DwadMainActivity.class));
}else if (v.getId()==dl.getId()&&e1.getText().length()>0) {
Toast.makeText(getApplicationContext(), "密码错误", 0).show();
}else{
Toast.makeText(getApplicationContext(), "请输入账号", 0).show();
}
}
}
DwadMainActivity
public class DwadMainActivity extends Activity implements OnItemLongClickListener {
ListView ls;
ArrayList<Sudent> date = new ArrayList<Sudent>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dwad_main);
ls=(ListView) findViewById(R.id.listView1);
ls.setAdapter( new MyAdapter());
date.add(new Sudent("张三","身高:188cm","体重:200kg"));
date.add(new Sudent("李四","身高:180cm","体重:100kg"));
date.add(new Sudent("王五","身高:148cm","体重:1400kg"));
date.add(new Sudent("马六","身高:188cm","体重:200kg"));
date.add(new Sudent("赵七","身高:178cm","体重:180kg"));
date.add(new Sudent("小明","身高:188cm","体重:148kg"));
date.add(new Sudent("大明","身高:188cm","体重:130kg"));
date.add(new Sudent("李四","身高:188cm","体重:150kg"));
date.add(new Sudent("王五","身高:188cm","体重:135kg"));
date.add(new Sudent("马六","身高:188cm","体重:145kg"));
date.add(new Sudent("张三","身高:188cm","体重:179kg"));
ls.setOnItemLongClickListener(this);
}
class MyAdapter extends BaseAdapter{
@Override
public int getCount() {
// TODO Auto-generated method stub
return date.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return date.get(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
if (convertView==null) {
convertView=View.inflate(getApplicationContext(), R.layout.nvgh, null);
}
Sudent sudent = date.get(position);
TextView t1=(TextView) convertView.findViewById(R.id.textView1);
TextView t2=(TextView) convertView.findViewById(R.id.textView2);
TextView t3=(TextView) convertView.findViewById(R.id.textView3);
t1.setText(sudent.getName());
t2.setText(sudent.getSg());
t3.setText(sudent.getTz());
return convertView;
}
}
AlertDialog create ;
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
int position, long id) {
final AlertDialog.Builder ad=new AlertDialog.Builder(this);
View inflate = View.inflate(getApplicationContext(), R.layout.tex, null);
LinearLayout qx = (LinearLayout) inflate.findViewById(R.id.qx);
qx.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
create.cancel();
}
});
ad.setView(inflate);
ad.setCancelable(false);
create = ad.create();
create.show();
return false;
}
}
Sudent:
public class Sudent {
String name;
String sg;
String tz;
public Sudent(){
}
public Sudent(String name, String sg, String tz) {
super();
this.name = name;
this.sg = sg;
this.tz = tz;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSg() {
return sg;
}
public void setSg(String sg) {
this.sg = sg;
}
public String getTz() {
return tz;
}
public void setTz(String tz) {
this.tz = tz;
}
}
activity_dwad_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="移动软件学院学员"
android:background="@drawable/top"
android:gravity="center"/>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:orientation="vertical"
android:layout_weight="1"
android:background="@drawable/bc"
>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:background="#eee685"
android:orientation="vertical" >
<EditText
android:id="@+id/EditText01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:background="#ffffff"
android:drawableLeft="@drawable/user"
android:layout_weight="1"
android:ems="10"
android:hint="请输入用户名"
android:textSize="15dp" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:drawableLeft="@drawable/pwd_lock"
android:background="#ffffff"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:hint="请输入密码"
android:textSize="15dp"
>
<requestFocus />
</EditText>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 记住密码"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_weight="3"
android:button="@drawable/drawanle"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/btn_login_normal"
android:layout_gravity="top|center"
android:layout_weight="3"
android:layout_marginTop="25dp"/>
</LinearLayout>
</LinearLayout>
nvgh.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/user"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="张三"
android:gravity="center_vertical"
android:textSize="20dp"
android:textColor="#000000"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="身高 123"
android:textColor="#3000ff"
android:gravity="center_vertical"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#3000ff"
android:text="体重 321"
android:gravity="center_vertical"/>
</LinearLayout>
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/arrows"
android:layout_weight="1"/>
</LinearLayout>
tex.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:text="警告"
android:textSize="20dp"
android:layout_weight="1"
android:drawableLeft="@drawable/user"
android:textColor="#0090ff"/>
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#0090ff" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_weight="1.00"
android:text="你没有权限删除!"
android:gravity="center"
android:textColor="#000000"
android:textSize="17dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#999999"/>
<LinearLayout
android:id="@+id/qx"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="0.23"
android:gravity="center"
android:text="取消"
android:textColor="#000000"
android:textSize="13dp" />
</LinearLayout>
</LinearLayout>
![](https://i-blog.csdnimg.cn/blog_migrate/2d4d1157ce277c0543bef20a7695fed7.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4b88104c93605aca763fadb9ad620481.png)