Android学生信息管理系统(2)查看全部学生信息界面设计

点击查看全部信息按钮弹出listview全部学生信息内容,也就是按钮5的点击事件,下期会出对应学生信息的增加,删除和修改!

activity_main3.xml




    

    


 list_item.xlml




    

    

        

        

        
    

 MainActivity.java

package com.example.android;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;


public class Main3Activity extends Activity implements AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {
    private ListView mListView;
    private String[] titles = {"橘右京", "马超", "李信", "关羽","杨戬","瑶","李白","干将莫邪"};
    private String[] prices = {"刺客/战士", "战士", "战士", "战士", "战士","辅助","刺客","法师"};

    private int[] icons = {R.drawable.apple, R.drawable.cake, R.drawable.table, R.drawable.kiwifruit,
            R.drawable.wireclothes,R.drawable.yao,R.drawable.iphone5s,R.drawable.gan};

    protected void onCreate(Bundle saveInstanceState) {
        super.onCreate(saveInstanceState);
        setContentView(R.layout.activity_main3);

        mListView = (ListView) findViewById(R.id.lv);

        MyBaseAdaPter mAdapter = new MyBaseAdaPter();

        mListView.setAdapter(mAdapter);
        
    }


    class MyBaseAdaPter extends BaseAdapter {
        @Override
        public int getCount() {
            return titles.length;
        }

        @Override
        public Object getItem(int position) {
            return titles[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder = null;
            if (convertView == null) {
                convertView = View.inflate(Main3Activity.this, R.layout.list_item, null);
                holder = new ViewHolder();
                holder.title = (TextView) convertView.findViewById(R.id.title);
                holder.price = (TextView) convertView.findViewById(R.id.price);
                holder.iv = (ImageView) convertView.findViewById(R.id.iv);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            holder.title.setText(titles[position]);
            holder.price.setText(prices[position]);
            holder.iv.setBackgroundResource(icons[position]);
            return convertView;
        }
    }

    static class ViewHolder {
        TextView title;
        TextView price;
        ImageView iv;
    }
}



 Main2Activity.java

package com.example.android;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Main2Activity extends AppCompatActivity {
private Button btn5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
btn5=findViewById(R.id.btn5);
btn5.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent=new Intent(Main2Activity.this,Main3Activity.class);
        startActivity(intent);
    }
});
    }
}

运行效果图

Android学生信息管理系统(2)查看全部学生信息界面设计_第1张图片

 Android学生信息管理系统(2)查看全部学生信息界面设计_第2张图片

 

你可能感兴趣的:(Android项目,android-studio,android学生学习管理系统)