XML代码
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.dell.xueguan.MainActivity"> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/xueguan" android:onClick="onClick" android:id="@+id/zhuomian"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="学员管理" android:textSize="20sp" android:layout_below="@+id/zhuomian" android:layout_marginLeft="10dp"/> </RelativeLayout>
JAVA代码
package com.example.dell.xueguan; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void onClick(View v) { Intent intent = new Intent(this,DengLuActivity.class); startActivity(intent); } }
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" android:background="@drawable/beijing" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入用户名" android:layout_marginTop="20dp" android:layout_marginLeft="20dp"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入密码" android:layout_marginTop="20dp" android:layout_marginLeft="20dp" android:password="true"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="注册" android:layout_weight="1" android:background="@drawable/zhuce" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="登陆" android:layout_weight="1" android:background="@drawable/zhuce" android:layout_marginRight="10dp" android:id="@+id/login" android:onClick="loginclick"/> </LinearLayout> </LinearLayout>
JAVA代码
package com.example.dell.xueguan; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; public class DengLuActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_deng_lu); //Button login = (Button)findViewById(R.id.login); } public void loginclick(View v) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage("请稍后......"); progressDialog.show(); final Intent intent = new Intent(this,jiemian1.class); new Thread() { @Override public void run() { super.run(); try { Thread.sleep(3000); } catch (Exception e) { } progressDialog.dismiss(); startActivity(intent); } }.start(); } }
XML代码
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.dell.xueguan.jiemian1" android:background="@drawable/jiemian1"> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/tianjia" android:id="@+id/tianjia" android:onClick="xuanke" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="学员列表" android:layout_below="@+id/tianjia" android:textSize="20sp" android:layout_marginLeft="10dp" /> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/jindu" android:id="@+id/jindu" android:layout_marginLeft="160dp" android:onClick="xiazai" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="课程下载" android:layout_below="@+id/jindu" android:textSize="20sp" android:layout_marginLeft="170dp" /> </RelativeLayout>
JAVA代码
package com.example.dell.xueguan; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; public class jiemian1 extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_jiemian1); } public void xuanke(View view) { Intent intent = new Intent(this,xueshenglibiao.class); startActivity(intent); } public void xiazai(View view){ } }
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="wrap_content"> <ImageView android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/touxiang1" android:id="@+id/tx_1"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_vertical" android:layout_marginLeft="20dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓名:赵四" android:id="@+id/tv_1"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="选择课程:英语" android:paddingTop="10dp" android:id="@+id/tv_2"/> </LinearLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/xueshengliebiao" > </ListView>
JAVA代码
package com.example.dell.xueguan; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class xueshenglibiao extends AppCompatActivity { List<XueYuanInfo> xyif; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_xueshenglibiao); ListView sa_1= (ListView)findViewById(R.id.xueshengliebiao); xyif = new ArrayList<XueYuanInfo>(); xyif.add(new XueYuanInfo(R.drawable.touxiang1,"赵四","语文")); xyif.add(new XueYuanInfo(R.drawable.touxiang2,"小明","数学")); xyif.add(new XueYuanInfo(R.drawable.touxiang13,"李磊","英语")); xyif.add(new XueYuanInfo(R.drawable.touxiang14,"憨豆","历史")); xyif.add(new XueYuanInfo(R.drawable.touxiang15,"七仔","地理")); xyif.add(new XueYuanInfo(R.drawable.touxiang16,"李东","语文")); xyif.add(new XueYuanInfo(R.drawable.touxiang17, "韩丽", "历史")); xyif.add(new XueYuanInfo(R.drawable.touxiang18,"刘璇","语文")); xyif.add(new XueYuanInfo(R.drawable.touxiang19,"张三","语文")); xyif.add(new XueYuanInfo(R.drawable.touxiang1,"王宇","语文")); xyif.add(new XueYuanInfo(R.drawable.touxiang2,"王武","语文")); sa_1.setAdapter(new MyAdapter()); } class MyAdapter extends BaseAdapter { @Override public int getCount() { return xyif.size(); } @Override public Object getItem(int position) { return xyif.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater layoutInflater = getLayoutInflater(); convertView = layoutInflater.inflate(R.layout.xueshengliebiaolayout,null); } XueYuanInfo xueYuanInfo = xyif.get(position); ImageView iv_1 = (ImageView)convertView.findViewById(R.id.tx_1); TextView tv_1 = (TextView)convertView.findViewById(R.id.tv_1); TextView tv_2 = (TextView)convertView.findViewById(R.id.tv_2); iv_1.setImageResource(xueYuanInfo.getImage()); tv_1.setText(xueYuanInfo.getName()); tv_2.setText(xueYuanInfo.getKecheng()); return convertView; } } }
package com.example.dell.xueguan; /** * Created by DELL on 2016/4/7. */ public class XueYuanInfo { private int image; private String name; private String kecheng; public int getImage() { return image; } public void setImage(int image) { this.image = image; } public String getKecheng() { return kecheng; } public void setKecheng(String kecheng) { this.kecheng = kecheng; } public String getName() { return name; } public void setName(String name) { this.name = name; } public XueYuanInfo(int image, String kecheng, String name) { this.image = image; this.kecheng = kecheng; this.name = name; } }