太原网站空间,wordpress做seo合适吗,专业做校园文化的网站,重庆潼南网站建设价格1、在Android Studio中#xff0c;请在第二次实验成果的基础上完成以下实验要求。
向右滑动 请添加登录页面。在登录页面中#xff0c;如果用户输入的用户名和密码正确#xff0c;则跳转至如上图所示的好友列表#xff0c;并记录用户的登录信息#xff0c;在用户第一次登…1、在Android Studio中请在第二次实验成果的基础上完成以下实验要求。
向右滑动 请添加登录页面。在登录页面中如果用户输入的用户名和密码正确则跳转至如上图所示的好友列表并记录用户的登录信息在用户第一次登录成功后再次打开App时直接登录进入到好友列表页面[1]如果用户输入的用户名和密码错误则以Toast方式提示用户输入的用户名或密码错误。
成功登录进入后侧滑菜单要求仍然可用。
使用SQLite构建内联数据库其中存储好友基本信息好友头像、好友名称、最后一次联系的单条消息、最后一次联系的时间。
在登录进入后通过SQLite数据库连接读取好友列表数据5条以上[2]并以List方式显示在页面上。
3、注意
① 请将补充的图片素材放入“根目录/Extra”
② 请将实验报告放入“根目录/Doc”。
运行效果 文件目录 在实验2中只建立了一个fragment,在这此实验为每一页创建了fragment但除了XiaoXiFragment,其他的fragment没有写入什么东西。沿用实验2的代码没有任何更改这里新加了几个文件。
DatabaseHelper.java
package com.example.TheSixthExperiment;import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;public class DatabaseHelper extends SQLiteOpenHelper {private static final String DATABASE_NAME friends_db.db;private static final int DATABASE_VERSION 1;// SQL语句创建表private static final String TABLE_CREATE CREATE TABLE friends ( id INTEGER PRIMARY KEY AUTOINCREMENT, avatar BLOB, name TEXT, last_message TEXT, last_contact TIMESTAMP);;public DatabaseHelper(Context context) {super(context, DATABASE_NAME, null, DATABASE_VERSION);}Overridepublic void onCreate(SQLiteDatabase db) {db.execSQL(TABLE_CREATE);}Overridepublic void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {// 如果数据库版本发生变化删除旧表并重新创建db.execSQL(DROP TABLE IF EXISTS friends);onCreate(db);}// 清空friends表中的数据但不删除表本身public void clearDatabase(){SQLiteDatabase db getWritableDatabase();// 使用DELETE语句清空表中的数据String deleteSQL DELETE FROM friends;db.execSQL(deleteSQL);}
}Friend.java
package com.example.TheSixthExperiment;public class Friend {private byte[] avatar;private String name;private String lastMessage;private String lastContact;public byte[] getAvatar() { return avatar; }public void setAvatar(byte[] avatar) { this.avatar avatar; }public String getName() { return name; }public void setName(String name) { this.name name; }public String getLastMessage() { return lastMessage; }public void setLastMessage(String lastMessage) { this.lastMessage lastMessage; }public String getLastContact() { return lastContact; }public void setLastContact(String lastContact) { this.lastContact lastContact; }
}FriendAdapter.java
package com.example.TheSixthExperiment;import android.content.Context;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;import java.util.List;public class FriendAdapter extends RecyclerView.AdapterFriendAdapter.FriendViewHolder {private Context context;private ListFriend friendList;public FriendAdapter(Context context, ListFriend friendList) {this.context context;this.friendList friendList;}NonNullOverridepublic FriendViewHolder onCreateViewHolder(NonNull ViewGroup parent, int viewType) {View view LayoutInflater.from(context).inflate(R.layout.friend_item, parent, false);return new FriendViewHolder(view);}Overridepublic void onBindViewHolder(NonNull FriendViewHolder holder, int position) {Friend friend friendList.get(position);holder.avatarImageView.setImageBitmap(BitmapFactory.decodeByteArray(friend.getAvatar(), 0, friend.getAvatar().length));holder.nameTextView.setText(friend.getName());holder.lastMessageTextView.setText(friend.getLastMessage());holder.lastContactTextView.setText(friend.getLastContact());}Overridepublic int getItemCount() {return friendList.size();}public static class FriendViewHolder extends RecyclerView.ViewHolder {ImageView avatarImageView;TextView nameTextView;TextView lastMessageTextView;TextView lastContactTextView;public FriendViewHolder(NonNull View itemView) {super(itemView);avatarImageView itemView.findViewById(R.id.iv_touxiang);nameTextView itemView.findViewById(R.id.tv_nicheng);lastMessageTextView itemView.findViewById(R.id.tv_xiaoxi);lastContactTextView itemView.findViewById(R.id.tv_shijian);}}
}LoginActivity.java
package com.example.TheSixthExperiment;import androidx.appcompat.app.AppCompatActivity;import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;public class LoginActivity extends AppCompatActivity {private EditText etUsername, etPassword;private Button btnLogin;private DatabaseHelper dbHelper;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_login);etUsername findViewById(R.id.et_username);etPassword findViewById(R.id.et_password);btnLogin findViewById(R.id.btn_login);SharedPreferences sharedPreferences getSharedPreferences(MyAppPref, MODE_PRIVATE);boolean isLoggedIn sharedPreferences.getBoolean(isLoggedIn, false);//isLoggedInfalse;//如果需要每次打开软件看到登陆界面if (isLoggedIn) {Intent intent new Intent(LoginActivity.this, MainActivity.class);startActivity(intent);finish();}btnLogin.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {String username etUsername.getText().toString();String password etPassword.getText().toString();if (cust.equals(username) 12345.equals(password)) {//同户名和密码位置在此处进行更改SharedPreferences.Editor editor sharedPreferences.edit();editor.putBoolean(isLoggedIn, true);editor.apply();addFriendData();Intent intent new Intent(LoginActivity.this, MainActivity.class);startActivity(intent);finish();} else {Toast.makeText(LoginActivity.this, 用户名或密码错误, Toast.LENGTH_SHORT).show();}}private void addFriendData() {dbHelper new DatabaseHelper(LoginActivity.this);dbHelper.clearDatabase();insertFriend(getBitmapAsByteArray(R.drawable.touxiang1), 马云, 支付宝转给你一千万记得查收一下, 2024-10-20);insertFriend(getBitmapAsByteArray(R.drawable.touxiang2), 马化腾, 以后还要你多多照顾, 2024-10-18);insertFriend(getBitmapAsByteArray(R.drawable.touxiang3), 范冰冰, 明天你有空吗, 2024-10-10);insertFriend(getBitmapAsByteArray(R.drawable.touxiang4), 雷军, 谢谢你对小米的照顾, 2024-10-8);insertFriend(getBitmapAsByteArray(R.drawable.touxiang5), 巴菲特, 有空能一起吃个饭吗, 2024-10-8);insertFriend(getBitmapAsByteArray(R.drawable.touxiang6), 比尔盖茨, 微软不能没有你啊, 2024-10-5);insertFriend(getBitmapAsByteArray(R.drawable.touxiang7), 马斯克, 你好, 2024-9-28);insertFriend(getBitmapAsByteArray(R.drawable.touxiang9), 张一鸣, 有问题想要请教你, 2024-9-28);insertFriend(getBitmapAsByteArray(R.drawable.touxiang10), 乔布斯, 你想接手苹果公司吗, 2024-9-26);insertFriend(getBitmapAsByteArray(R.drawable.touxiang11), 乔丹, 我会回来的, 2024-9-24);insertFriend(getBitmapAsByteArray(R.drawable.touxiang12), 周鸿祎, 谢谢你对360的支持, 2024-9-20);insertFriend(getBitmapAsByteArray(R.drawable.touxiang13), 王建林, 谢谢你借钱给我, 2024-9-20);insertFriend(getBitmapAsByteArray(R.drawable.touxiang8), 迪迦凹凸曼, 什么时候和我回光之国, 2024-9-1);}});}private void insertFriend(byte[] avatar, String name, String lastMessage, String lastContact) {SQLiteDatabase db dbHelper.getWritableDatabase();ContentValues values new ContentValues();values.put(avatar, avatar);values.put(name, name);values.put(last_message, lastMessage);values.put(last_contact, lastContact);db.insert(friends, null, values);}public byte[] getBitmapAsByteArray(int resourceId) {InputStream inputStream getResources().openRawResource(resourceId);byte[] avatarData null;try (ByteArrayOutputStream byteArrayOutputStream new ByteArrayOutputStream()) {int bufferSize 1024;byte[] buffer new byte[bufferSize];int length;while ((length inputStream.read(buffer)) 0) {byteArrayOutputStream.write(buffer, 0, length);}avatarData byteArrayOutputStream.toByteArray();} catch (IOException e) {e.printStackTrace();} finally {try {if (inputStream ! null) {inputStream.close();}} catch (IOException ex) {ex.printStackTrace();}}return avatarData;}
}MainActivity.java
package com.example.TheSixthExperiment;import android.app.AlertDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;public class MainActivity extends AppCompatActivity {private HorizontalScrollView horizontalScrollView;private ImageView erweima, quxiao;private LinearLayout llxiaoxi, llpindao, lllianxiren, lldongtai, button1, button2, button3, button4, button5;private ImageView ivxiaoxi, ivpindao, ivlianxiren, ivdonngtai;private TextView tvxiaoxi, tvpindao, tvlianxiren, tvdongtai;FragmentManager fragmentManager;FragmentTransaction fragmentTransaction;DongTaiFragment dongTaiFragment;LianXiRenFragment lianXiRenFragment;PinDaoFragment pinDaoFragment;XiaoXiFragment xiaoXiFragment;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initView();initEvent();setupButtonListeners();}private void initEvent() {fragmentManager getSupportFragmentManager();fragmentTransaction fragmentManager.beginTransaction();ivxiaoxi.setImageResource(R.drawable.xiaoxi2);tvxiaoxi.setTextColor(getResources().getColor(R.color.blue));fragmentTransaction.replace(R.id.fcv_fragment, xiaoXiFragment).commit();}private void initView() {llxiaoxi findViewById(R.id.ll_xiaoxi);ivxiaoxi findViewById(R.id.iv_xiaoxi);tvxiaoxi findViewById(R.id.tv_xiaoxi);llpindao findViewById(R.id.ll_pindao);ivpindao findViewById(R.id.iv_pindao);tvpindao findViewById(R.id.tv_pindao);lllianxiren findViewById(R.id.ll_lianxiren);ivlianxiren findViewById(R.id.iv_lianxiren);tvlianxiren findViewById(R.id.tv_lianxiren);lldongtai findViewById(R.id.ll_dongtai);ivdonngtai findViewById(R.id.iv_dongtai);tvdongtai findViewById(R.id.tv_dongtai);erweima findViewById(R.id.erweima);quxiao findViewById(R.id.quxiao);button1 findViewById(R.id.button1);button2 findViewById(R.id.button2);button3 findViewById(R.id.button3);button4 findViewById(R.id.button4);button5 findViewById(R.id.button5);horizontalScrollView findViewById(R.id.mhsv);dongTaiFragmentnew DongTaiFragment();lianXiRenFragmentnew LianXiRenFragment();pinDaoFragmentnew PinDaoFragment();xiaoXiFragmentnew XiaoXiFragment();}private void setupButtonListeners() {button1.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) { showToast(笑脸); }});button2.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {showToast(电话);}});button3.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {showToast(点赞);}});button4.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {showToast(发现);}});button5.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {showToast(标签);}});erweima.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {horizontalScrollView.smoothScrollTo(10000, 0);showImageDialog();}});quxiao.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {horizontalScrollView.smoothScrollTo(10000, 0);}});lllianxiren.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {initDaoHang();fragmentManager getSupportFragmentManager();fragmentTransaction fragmentManager.beginTransaction();fragmentTransaction.replace(R.id.fcv_fragment, lianXiRenFragment).commit();ivlianxiren.setImageResource(R.drawable.lianxiren2);tvlianxiren.setTextColor(getResources().getColor(R.color.blue));}});llxiaoxi.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {initDaoHang();fragmentManager getSupportFragmentManager();fragmentTransaction fragmentManager.beginTransaction();fragmentTransaction.replace(R.id.fcv_fragment, xiaoXiFragment).commit();ivxiaoxi.setImageResource(R.drawable.xiaoxi2);tvxiaoxi.setTextColor(getResources().getColor(R.color.blue));}});llpindao.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {initDaoHang();fragmentManager getSupportFragmentManager();fragmentTransaction fragmentManager.beginTransaction();fragmentTransaction.replace(R.id.fcv_fragment, pinDaoFragment).commit();ivpindao.setImageResource(R.drawable.pingdao2);tvpindao.setTextColor(getResources().getColor(R.color.blue));}});lldongtai.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {initDaoHang();fragmentManager getSupportFragmentManager();fragmentTransaction fragmentManager.beginTransaction();fragmentTransaction.replace(R.id.fcv_fragment, dongTaiFragment).commit();ivdonngtai.setImageResource(R.drawable.dongtai2);tvdongtai.setTextColor(getResources().getColor(R.color.blue));}});}private void showToast(String message) {Toast.makeText(this, message, Toast.LENGTH_SHORT).show();}private void showImageDialog() {AlertDialog.Builder builder new AlertDialog.Builder(this);LayoutInflater inflater getLayoutInflater();View dialogView inflater.inflate(R.layout.custom_dialog_layout, null);ImageView dialogImageView dialogView.findViewById(R.id.dialog_image_view);dialogImageView.setImageResource(R.drawable.cust);builder.setView(dialogView).setCancelable(true);AlertDialog alertDialog builder.create();alertDialog.show();}private void initDaoHang() {ivlianxiren.setImageResource(R.drawable.lianxiren1);tvlianxiren.setTextColor(getResources().getColor(R.color.black));ivpindao.setImageResource(R.drawable.pingdao1);tvpindao.setTextColor(getResources().getColor(R.color.black));ivdonngtai.setImageResource(R.drawable.dongtai1);tvdongtai.setTextColor(getResources().getColor(R.color.black));ivxiaoxi.setImageResource(R.drawable.xiaoxi1);tvxiaoxi.setTextColor(getResources().getColor(R.color.black));}
}XiaoXiFragment.java
package com.example.TheSixthExperiment;import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;import java.util.ArrayList;
import java.util.List;public class XiaoXiFragment extends Fragment {private RecyclerView recyclerView;private FriendAdapter friendAdapter;private ListFriend friendList;private DatabaseHelper dbHelper;Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {// 初始化布局View view inflater.inflate(R.layout.fragment_xiao_xi, container, false);recyclerView view.findViewById(R.id.recyclerView);dbHelper new DatabaseHelper(getActivity()); // 使用getActivity()获取上下文// 从数据库读取数据friendList getFriendsFromDatabase();// 设置RecyclerViewrecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));friendAdapter new FriendAdapter(getActivity(), friendList);recyclerView.setAdapter(friendAdapter);return view;}private ListFriend getFriendsFromDatabase() {ListFriend friends new ArrayList();SQLiteDatabase db dbHelper.getReadableDatabase();Cursor cursor db.query(friends, new String[]{id, avatar, name, last_message, last_contact},null, null, null, null, id ASC);while (cursor.moveToNext()) {Friend friend new Friend();friend.setAvatar(cursor.getBlob(cursor.getColumnIndex(avatar)));friend.setName(cursor.getString(cursor.getColumnIndex(name)));friend.setLastMessage(cursor.getString(cursor.getColumnIndex(last_message)));friend.setLastContact(cursor.getString(cursor.getColumnIndex(last_contact)));friends.add(friend);}cursor.close();return friends;}
}MyHorizontalScrollVie.java
package com.example.TheSixthExperiment;import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;public class MyHorizontalScrollView extends HorizontalScrollView {//滚动条中的水平先行布局private LinearLayout mWrpper;//水平线性布局的左侧菜单menuprivate ViewGroup mMenu;//水平先行布局的右侧线性布局private ViewGroup mContent;//屏幕的宽private int mScreenWidth;//menu的宽离屏幕右侧的距离private int mMenuRightPadding50;//menu的宽度private int mMenuWidth;private boolean once;/*** 未使用自定义属性时调用* */public MyHorizontalScrollView(Context context, AttributeSet attrs) {super(context, attrs);/** 获取屏幕的宽度* 通过context拿到windowManager在通过windowManager拿到Metrics,用DisplayMetrics接收* */WindowManager wm (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);DisplayMetrics outMetrics new DisplayMetrics();wm.getDefaultDisplay().getMetrics(outMetrics);mScreenWidthoutMetrics.widthPixels;//把dp转换成pxmMenuRightPadding(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50,context.getResources().getDisplayMetrics());}/** 设置子view的宽和高* */Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {// TODO Auto-generated method stubif(!once){mWrpper(LinearLayout) getChildAt(0);mMenu(ViewGroup) mWrpper.getChildAt(0);mContent(ViewGroup) mWrpper.getChildAt(1);//menu的宽度等于屏幕的宽度减去menu离屏幕右侧的边距mMenuWidthmMenu.getLayoutParams().widthmScreenWidth;//右边的先行布局的宽度直接等于屏幕的宽度mContent.getLayoutParams().widthmScreenWidth;oncetrue;}super.onMeasure(widthMeasureSpec, heightMeasureSpec);}/** 通过设置偏移量将menu隐藏* */Overrideprotected void onLayout(boolean changed, int l, int t, int r, int b) {// TODO Auto-generated method stubsuper.onLayout(changed, l, t, r, b);/** 通过scrollTox,y方法设置屏幕的偏移量x为正* 内容向左移动* */if(changed){this.scrollTo(mMenuWidth, 0);}}/** 因为HorizontalScrollView自己控制move和down的事件* 所以我们还要判断一下up.如果当前的x偏移量大于menu宽度的一半* 隐藏menu否则显示menu* */Overridepublic boolean onTouchEvent(MotionEvent ev) {// TODO Auto-generated method stubint actionev.getAction();switch(action){case MotionEvent.ACTION_UP:int scrollXgetScrollX();if(scrollXmMenuWidth/2){this.smoothScrollTo(mMenuWidth, 0);}else{this.smoothScrollTo(0, 0);}return true;}return super.onTouchEvent(ev);}
}activity_ login.xml
?xml version1.0 encodingutf-8?
LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:gravitycenterandroid:orientationverticalandroid:padding16dpEditTextandroid:idid/et_usernameandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:hintUsername:custandroid:inputTypetext /EditTextandroid:idid/et_passwordandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_marginTop16dpandroid:hintPassword:12345android:inputTypetextPassword /Buttonandroid:idid/btn_loginandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_marginTop16dpandroid:textLogin //LinearLayoutactivity_main.xml
?xml version1.0 encodingutf-8?
com.example.TheSixthExperiment.MyHorizontalScrollView xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoandroid:idid/mhsvandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:scrollbarsnoneLinearLayoutandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_gravitycenter_verticalandroid:orientationhorizontalinclude layoutlayout/meum /LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalandroidx.fragment.app.FragmentContainerViewandroid:idid/fcv_fragmentandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:layout_weight1/includelayoutlayout/daohangandroid:layout_widthmatch_parentandroid:layout_heightwrap_content //LinearLayout/LinearLayout
/com.example.TheSixthExperiment.MyHorizontalScrollViewcustom _dialog_layout.xml
?xml version1.0 encodingutf-8?
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthfill_parentandroid:layout_heightfill_parentImageViewandroid:idid/dialog_image_viewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_centerInParenttrueandroid:srcdrawable/cust /
/RelativeLayoutdaohang.xml
?xml version1.0 encodingutf-8?
LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_alignParentBottomtrueandroid:backgroundcolor/whiteandroid:orientationhorizontalLinearLayoutandroid:idid/ll_xiaoxiandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1android:background?attr/selectableItemBackgroundandroid:clickabletrueandroid:gravitycenter_horizontalandroid:orientationverticalImageViewandroid:idid/iv_xiaoxiandroid:layout_width40dpandroid:layout_height40dpandroid:srcdrawable/xiaoxi1 /TextViewandroid:idid/tv_xiaoxiandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text消息android:textSize20sp //LinearLayoutLinearLayoutandroid:idid/ll_pindaoandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1android:background?attr/selectableItemBackgroundandroid:clickabletrueandroid:gravitycenter_horizontalandroid:orientationverticalImageViewandroid:idid/iv_pindaoandroid:layout_width40dpandroid:layout_height40dpandroid:srcdrawable/pingdao1 /TextViewandroid:idid/tv_pindaoandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text频道android:textSize20sp //LinearLayoutLinearLayoutandroid:idid/ll_lianxirenandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1android:background?attr/selectableItemBackgroundandroid:clickabletrueandroid:gravitycenter_horizontalandroid:orientationverticalImageViewandroid:idid/iv_lianxirenandroid:layout_width40dpandroid:layout_height40dpandroid:srcdrawable/lianxiren1 /TextViewandroid:idid/tv_lianxirenandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text联系人android:textSize20sp //LinearLayoutLinearLayoutandroid:idid/ll_dongtaiandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1android:background?attr/selectableItemBackgroundandroid:clickabletrueandroid:gravitycenter_horizontalandroid:orientationverticalImageViewandroid:idid/iv_dongtaiandroid:layout_width40dpandroid:layout_height40dpandroid:srcdrawable/dongtai1 /TextViewandroid:idid/tv_dongtaiandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text动态android:textSize20sp //LinearLayout/LinearLayoutfragment_ xiao_ xi.xml
?xml version1.0 encodingutf-8?
FrameLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:idid/fragment_root_viewandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.XiaoXiFragmentandroidx.recyclerview.widget.RecyclerViewandroid:idid/recyclerViewandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:padding8dpandroid:scrollbarsvertical //FrameLayoutfriend_item.xml
?xml version1.0 encodingutf-8?
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentImageViewandroid:idid/iv_touxiangandroid:layout_width60dpandroid:layout_height60dpandroid:padding5dp /TextViewandroid:idid/tv_nichengandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize20spandroid:layout_toRightOfid/iv_touxiang/TextViewandroid:idid/tv_xiaoxiandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize15spandroid:layout_toRightOfid/iv_touxiangandroid:layout_belowid/tv_nicheng/TextViewandroid:idid/tv_shijianandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_alignParentRighttrueandroid:layout_marginRight50dpandroid:layout_marginTop5dp//RelativeLayoutmeum.xml
?xml version1.0 encodingutf-8?
RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoandroid:layout_widthfill_parentandroid:layout_heightfill_parentandroid:background#ffffffandroid:orientationverticalImageViewandroid:idid/erweimaandroid:layout_width60dpandroid:layout_height60dpandroid:layout_alignParentToptrueandroid:layout_alignParentRighttrueandroid:layout_marginTop163dpandroid:padding10dpandroid:srcdrawable/erweima /ImageViewandroid:idid/quxiaoandroid:layout_width60dpandroid:layout_height60dpandroid:layout_alignParentToptrueandroid:layout_alignParentRighttrueandroid:layout_marginRight3dpandroid:clickabletrueandroid:padding10dpandroid:srcdrawable/quxiao /LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_alignParentBottomtrueandroid:layout_marginBottom175dpandroid:orientationverticalandroid:padding10dpLinearLayoutandroid:idid/button1android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:background?attr/selectableItemBackgroundandroid:clickabletrueandroid:orientationhorizontalImageViewandroid:idid/imageView1android:layout_width41dpandroid:layout_height41dpandroid:srcdrawable/xiaolianapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparentapp:layout_constraintWidth_percent0.3 /TextViewandroid:idid/textView1android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeft10dpandroid:paddingTop10dpandroid:text笑脸android:textColor#000000app:layout_constraintBottom_toBottomOfid/imageView1app:layout_constraintStart_toEndOfid/imageView1app:layout_constraintTop_toTopOfparent //LinearLayoutLinearLayoutandroid:idid/button2android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:background?attr/selectableItemBackgroundandroid:clickabletrueImageViewandroid:idid/imageView2android:layout_width41dpandroid:layout_height41dpandroid:srcdrawable/dianhuaapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparentapp:layout_constraintWidth_percent0.3 / !-- 可选设置相对宽度 --TextViewandroid:idid/textView2android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeft10dpandroid:paddingTop10dpandroid:text电话android:textColor#000000app:layout_constraintBottom_toBottomOfid/imageView1app:layout_constraintStart_toEndOfid/imageView1app:layout_constraintTop_toTopOfparent //LinearLayoutLinearLayoutandroid:idid/button3android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:background?attr/selectableItemBackgroundandroid:clickabletrueImageViewandroid:idid/imageView3android:layout_width41dpandroid:layout_height41dpandroid:srcdrawable/dianzanapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparentapp:layout_constraintWidth_percent0.3 / !-- 可选设置相对宽度 --TextViewandroid:idid/textView3android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeft10dpandroid:paddingTop10dpandroid:text点赞android:textColor#000000app:layout_constraintBottom_toBottomOfid/imageView1app:layout_constraintStart_toEndOfid/imageView1app:layout_constraintTop_toTopOfparent //LinearLayoutLinearLayoutandroid:idid/button4android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:background?attr/selectableItemBackgroundandroid:clickabletrueImageViewandroid:idid/imageView4android:layout_width41dpandroid:layout_height41dpandroid:srcdrawable/faxianapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparentapp:layout_constraintWidth_percent0.3 / !-- 可选设置相对宽度 --TextViewandroid:idid/textView4android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeft10dpandroid:paddingTop10dpandroid:text发现android:textColor#000000app:layout_constraintBottom_toBottomOfid/imageView1app:layout_constraintStart_toEndOfid/imageView1app:layout_constraintTop_toTopOfparent //LinearLayoutLinearLayoutandroid:idid/button5android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:background?attr/selectableItemBackgroundandroid:clickabletrueImageViewandroid:idid/imageView5android:layout_width41dpandroid:layout_height41dpandroid:srcdrawable/biaoqianapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparentapp:layout_constraintWidth_percent0.3 / !-- 可选设置相对宽度 --TextViewandroid:idid/textView5android:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeft10dpandroid:paddingTop10dpandroid:text标签android:textColor#000000app:layout_constraintBottom_toBottomOfid/imageView1app:layout_constraintStart_toEndOfid/imageView1app:layout_constraintTop_toTopOfparent //LinearLayout/LinearLayout/RelativeLayoutcolors.xml
?xml version1.0 encodingutf-8?
resourcescolor namepurple_200#FFBB86FC/colorcolor namepurple_500#FF6200EE/colorcolor namepurple_700#FF3700B3/colorcolor nameteal_200#FF03DAC5/colorcolor nameteal_700#FF018786/colorcolor nameblack#FF000000/colorcolor namewhite#FFFFFFFF/colorcolor nameblue#1296db/color
/resourcesAndroidManifest.xml(请注意这个代码的结构)
?xml version1.0 encodingutf-8?
manifest xmlns:androidhttp://schemas.android.com/apk/res/androidpackagecom.example.TheSixthExperimentapplicationandroid:allowBackuptrueandroid:iconmipmap/ic_launcherandroid:labelstring/app_nameandroid:roundIconmipmap/ic_launcher_roundandroid:supportsRtltrueandroid:themestyle/Theme.TheSecondactivity android:namecom.example.TheSixthExperiment.LoginActivityintent-filteraction android:nameandroid.intent.action.MAIN /category android:nameandroid.intent.category.LAUNCHER //intent-filter/activityactivity android:namecom.example.TheSixthExperiment.MainActivity/activity/application/manifest工程文件
通过网盘分享的文件TheSixthExperiment.zip 链接:https://pan.baidu.com/s/1_3GeK8TAfbmL1ygiiV7xtQ?pwd4v6d 提取码: 4v6d
gitee:android studio: 移动应用开发实验代码