主界面

上一篇文章的链接:

Android Studio 制作微信界面 上_nazonomaster的博客-CSDN博客https://blog.csdn.net/nazonomaster/article/details/124456716

接下来创建fragment的Java文件

首先是WeixinFragment.java

在包内创建一个名为fragment的文件夹,在该文件夹中创建新的Java类并命名为WeixinFragment

public class WeixinFragment extends Fragment {private List<Weixin> weiList = new ArrayList<>();@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {return inflater.inflate(R.layout.weixin_fragment,container,false);}@Overridepublic void onActivityCreated(@Nullable Bundle savedInstanceState) {super.onActivityCreated(savedInstanceState);inints();WeixinAdapter adapter = new WeixinAdapter(this.getContext(),R.layout.weixin_content_item,weiList);ListView listView = getView().findViewById(R.id.weixin_listview);listView.setAdapter(adapter);listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {Weixin weixin = weiList.get(position);if (weixin.getName()=="笨笨"){Intent intent = new Intent(getActivity(), ChatActivity.class);startActivity(intent);}else {Toast.makeText(getActivity(),"不是通讯录里的联系人( ´_ゝ`)", Toast.LENGTH_SHORT).show();}}});}private void inints() {for (int i=0; i<2;i++){Weixin w1 = new Weixin();w1.setImageId(R.mipmap.dingyuehao);w1.setName("订阅号服务");w1.setNeirong("重庆科技学院:今晚,重科人用歌声献礼建党100周年!");weiList.add(w1);Weixin w2 = new Weixin();w2.setImageId(R.mipmap.yundong);w2.setName("运动健康");w2.setNeirong("[应用消息]");weiList.add(w2);Weixin w3 = new Weixin();w3.setImageId(R.mipmap.weixinzhifu);w3.setName("微信支付");w3.setNeirong("微信支付凭证");weiList.add(w3);Weixin w4 = new Weixin();w4.setImageId(R.mipmap.jizhangben);w4.setName("微信记账本");w4.setNeirong("昨日记账日报,点击查看详情");weiList.add(w4);Weixin w5 = new Weixin();w5.setImageId(R.mipmap.youxiang);w5.setName("QQ邮箱提醒");w5.setNeirong("Nintendo (Hongkong) Limited:最后召集! ...");weiList.add(w5);Weixin w6 = new Weixin();w6.setImageId(R.mipmap.haer);w6.setName("笨笨");w6.setNeirong("long may the sunshine!");weiList.add(w6);}}
}

第二个是TongxunluFragment.java

在fragment文件夹中创建新的Java类并命名为TongxunluFragment

public class TongxunluFragment extends Fragment {private List<Tongxunlu> tongxunluList = new ArrayList<>();@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {return inflater.inflate(R.layout.tongxunlu_fragment,container,false);}@Overridepublic void onActivityCreated(@Nullable Bundle savedInstanceState) {super.onActivityCreated(savedInstanceState);inints();TongxunluAdapter adapter = new TongxunluAdapter(this.getContext(),R.layout.txl_content_item,tongxunluList);ListView listView = getView().findViewById(R.id.txl_listview);listView.setAdapter(adapter);}private void inints() {Tongxunlu t1 = new Tongxunlu();t1.setImageId(R.mipmap.newf);t1.setName("新的朋友");tongxunluList.add(t1);Tongxunlu t2 = new Tongxunlu();t2.setImageId(R.mipmap.qunchat);t2.setName("群聊");tongxunluList.add(t2);Tongxunlu t3 = new Tongxunlu();t3.setImageId(R.mipmap.biaoqian);t3.setName("标签");tongxunluList.add(t3);Tongxunlu t4 = new Tongxunlu();t4.setImageId(R.mipmap.gongzhonghao);t4.setName("公众号");tongxunluList.add(t4);for (int i=0;i<2;i++){Tongxunlu t5 = new Tongxunlu();t5.setImageId(R.mipmap.t_tx01);t5.setName("笨笨");tongxunluList.add(t5);Tongxunlu t6 = new Tongxunlu();t6.setImageId(R.mipmap.t_tx02);t6.setName(" d=( ゚∀。)-好耶");tongxunluList.add(t6);Tongxunlu t7 = new Tongxunlu();t7.setImageId(R.mipmap.t_tx03);t7.setName("Hollow Knight");tongxunluList.add(t7);Tongxunlu t8 = new Tongxunlu();t8.setImageId(R.mipmap.t_tx05);t8.setName("Mr_Quin");tongxunluList.add(t8);Tongxunlu t9 = new Tongxunlu();t9.setImageId(R.mipmap.t_tx04);t9.setName("是acc啦");tongxunluList.add(t9);Tongxunlu t10 = new Tongxunlu();t10.setImageId(R.mipmap.tx_kenny);t10.setName("机智的肯尼");tongxunluList.add(t10);}}}

第三个是FaxianFragment.java

在fragment文件夹中创建新的Java类并命名为FaxianFragment

public class FaxianFragment extends Fragment  {private LinearLayout linearLayout;@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {View view = inflater.inflate(R.layout.faxian_fragment, container, false);RelativeLayout relativeLayout = view.findViewById(R.id.pyquan_click);relativeLayout.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Intent intent = new Intent(getActivity(),PyquanActivity.class);startActivity(intent);}});;return view;}}

最后是WodeFragemnt.java

在fragment文件夹中创建新的Java类并命名为WodeFragemnt

public class WodeFragemnt extends Fragment {@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {return inflater.inflate(R.layout.wode_fragment,container,false);}
}

菜单按钮布局

menu_weixin_icon_selector.xml

首先是第一个按钮的布局文件,在main\res\drawable中创建一个新的布局文件并命名为menu_weixin_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@mipmap/faxian02" android:state_pressed="true"/><item android:drawable="@mipmap/faxian02" android:state_selected="true"/><item android:drawable="@mipmap/faxian01"/>
</selector>

menu_tongxunlu_icon_selector.xml

第二个按钮的布局文件,在main\res\drawable中创建一个新的布局文件并命名为menu_tongxunlu_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@mipmap/tongxunlu02" android:state_pressed="true"/><item android:drawable="@mipmap/tongxunlu02" android:state_selected="true"/><item android:drawable="@mipmap/tongxunlu01"/>
</selector>

menu_faxian_icon_selector.xml

第三个按钮的布局文件,在main\res\drawable中创建一个新的布局文件并命名为menu_faxian_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@mipmap/faxian02" android:state_pressed="true"/><item android:drawable="@mipmap/faxian02" android:state_selected="true"/><item android:drawable="@mipmap/faxian01"/>
</selector>

menu_wode_icon_selector.xml

第四个按钮的布局文件,在main\res\drawable中创建一个新的布局文件并命名为menu_wode_icon_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@mipmap/wode02" android:state_pressed="true"/><item android:drawable="@mipmap/wode02" android:state_selected="true"/><item android:drawable="@mipmap/wode01"/>
</selector>

首页界面

布局文件weixin_content_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns: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:orientation="vertical"tools:ignore="MissingDefaultResource"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"android:layout_marginTop="5dp"><ImageViewandroid:id="@+id/weixin_content_img"android:layout_width="48dp"android:layout_height="48dp"android:src="@mipmap/dingyuehao"android:layout_marginLeft="10dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginLeft="10dp"android:orientation="vertical"><TextViewandroid:id="@+id/weixin_content_txt1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="订阅号消息"android:textSize="24sp"android:textColor="#000000"/><TextViewandroid:id="@+id/weixin_content_txt2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="重庆科技学院:今晚,重科人用歌声献..."android:textSize="15sp"/><Viewandroid:layout_width="match_parent"android:layout_height="2dp"android:background="#d8dde1"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></LinearLayout></LinearLayout>
</LinearLayout>

Weixin.java

在包内创建一个新的文件夹entity,在该文件夹中创建新的Java类,命名为Weixin

public class Weixin {private String name;private String neirong;private int imageId;public String getName() {return name;}public void setName(String name) {this.name = name;}public String getNeirong() {return neirong;}public void setNeirong(String neirong) {this.neirong = neirong;}public int getImageId() {return imageId;}public void setImageId(int imageId) {this.imageId = imageId;}
}

WeixinAdapter.java

在包内创建一个新的文件夹adapter,在该文件夹中创建新的Java类,命名为WeixinAdapter

public class WeixinAdapter extends ArrayAdapter<Weixin> {private int resourceId;private static final String TAG = "WeixinAdapter";private List<Weixin> list;public WeixinAdapter(@NonNull Context context, int resource, @NonNull List<Weixin> objects) {super(context, resource, objects);resourceId = resource;}@NonNull@Overridepublic View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){Weixin weixin = getItem(position);View view = LayoutInflater.from(getContext()).inflate(resourceId,parent, false);ImageView fruitImage = view.findViewById(R.id.weixin_content_img);TextView fruitName = view.findViewById(R.id.weixin_content_txt1);TextView fruitNr = view.findViewById(R.id.weixin_content_txt2);fruitImage.setImageResource(weixin.getImageId());fruitName.setText(weixin.getName());fruitNr.setText(weixin.getNeirong());return view;}
}

这样首页部分就完成了。

通讯录界面

布局文件txl_content_item.xml

在layout文件夹中创建一个名为txl_content_item的布局文件。

<?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"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><ImageViewandroid:id="@+id/t_tx"android:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/newf"android:layout_marginTop="5dp"android:layout_marginLeft="10dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:layout_marginLeft="10dp"><TextViewandroid:id="@+id/t_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="新的朋友"android:textSize="19dp"android:textColor="#000000"android:layout_marginTop="10dp"/><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginTop="20dp"android:background="#e0e0e0"/></LinearLayout></LinearLayout></LinearLayout>

Tongxunlu.java

在entity文件夹中创建一个名为Tongxunlu的Java类文件

public class Tongxunlu {private String name;private int imageId;public String getName(){return name;}public void setName(String name){this.name = name;}public int getImageId(){return imageId;}public void setImageId(int imageId) {this.imageId = imageId;}
}

TongxunluAdapter.java

在adapter文件夹中创建一个名为TongxunluAdapter的Java类文件

public class TongxunluAdapter extends ArrayAdapter<Tongxunlu> {private int resourceId;private static final String TAG = "TongxunluAdapter";private List<Tongxunlu> list;public TongxunluAdapter(@NonNull Context context, int resource, @NonNull List<Tongxunlu> objects) {super(context, resource, objects);resourceId = resource;}@NonNull@Overridepublic View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){Tongxunlu tongxunlu = getItem(position);View view = LayoutInflater.from(getContext()).inflate(resourceId,parent, false);ImageView t_tx = view.findViewById(R.id.t_tx);TextView t_name = view.findViewById(R.id.t_name);t_tx.setImageResource(tongxunlu.getImageId());t_name.setText(tongxunlu.getName());return view;}
}

聊天功能的实现

聊天界面布局activity_chat.xml

在layout文件夹中创建一个名为activity_chat的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="#d8e0e8"tools:context=".ChatActivity"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:background="#f2f2f2"><Buttonandroid:id="@+id/weixin_back"android:layout_width="40dp"android:layout_height="40dp"android:layout_alignParentLeft="true"android:layout_marginLeft="10dp"android:layout_marginTop="12dp"android:background="@mipmap/back" /><TextViewandroid:id="@+id/chat_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="笨笨"android:textSize="25dp"android:textColor="#000000"android:layout_centerHorizontal="true"android:layout_marginTop="15dp"/><Buttonandroid:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/ddd"android:layout_alignParentRight="true"android:layout_marginTop="12dp"android:layout_marginRight="10dp"/></RelativeLayout><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/msg_recycler_view"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="60dp"android:orientation="horizontal"android:background="#f2f2f2"><Buttonandroid:id="@+id/yuyin"android:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/yuyin"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><EditTextandroid:id="@+id/input_txt"android:layout_width="0dp"android:layout_height="42dp"android:layout_marginLeft="20dp"android:layout_marginTop="10dp"android:layout_toRightOf="@+id/yuyin"android:layout_toLeftOf="@+id/send_emoji"android:layout_marginRight="10dp"android:background="#ffffff" /><Buttonandroid:id="@+id/send_emoji"android:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/fabiaoqing"android:layout_marginTop="10dp"android:layout_marginRight="5dp"android:layout_toLeftOf="@+id/btn_send"/><Buttonandroid:id="@+id/btn_send"android:layout_width="60dp"android:layout_height="40dp"android:text="发送"android:textColor="#ffffff"android:textSize="20sp"android:background="#32dc60"android:layout_alignParentRight="true"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout>

聊天框的布局msg_item.xml

在layout文件夹中创建一个名为msg_item的布局文件

代码中涉及到聊天框的图片和路径,图片文件保存在res/mipmap_hdpi中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="wrap_content"android:padding="10dp"><LinearLayoutandroid:id="@+id/left_layout"android:layout_gravity="left"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"android:background="@mipmap/message_left"><TextViewandroid:id="@+id/left_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_margin="10dp"android:textColor="#fff"android:text="你好,小明"/></LinearLayout><LinearLayoutandroid:id="@+id/right_layout"android:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@mipmap/message_right"android:layout_gravity="right"><TextViewandroid:id="@+id/right_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_margin="10dp"android:text="我杀你妈"/></LinearLayout>
</LinearLayout>

Msg.java

在entity文件夹中创建一个名为Msg的Java类文件

public class Msg {public static final int TYPE_RECEIVED = 0;public static final int TYPE_SENT = 1;// 消息内容private String content;// 消息类型private int type;public Msg(String content,int type){this.content = content;this.type = type;}public int getType(){return type;}public String getContent(){return content;}public void setContent(String content){this.content = content;}public void setType(int type){this.type = type;}
}

MsgAdapter.java

在adapter文件夹中创建一个名为MsgAdapter的Java类文件

public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.ViewHolder> {private List<Msg> mMsgList;static class ViewHolder extends RecyclerView.ViewHolder{LinearLayout leftLayout;LinearLayout rightLayout;TextView leftMsg;TextView rightMsg;public ViewHolder(View view){super(view);leftLayout = (LinearLayout) view.findViewById(R.id.left_layout);rightLayout = (LinearLayout) view.findViewById(R.id.right_layout);leftMsg = (TextView) view.findViewById(R.id.left_msg);rightMsg = (TextView) view.findViewById(R.id.right_msg);}}public MsgAdapter(List<Msg> msgList){mMsgList = msgList;}@Overridepublic ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.msg_item,parent,false);return new ViewHolder(view);}@Overridepublic void onBindViewHolder(ViewHolder holder,int position){Msg msg = mMsgList.get(position);if (msg.getType() == Msg.TYPE_RECEIVED) {holder.leftLayout.setVisibility(View.VISIBLE);holder.rightLayout.setVisibility(View.GONE);holder.leftMsg.setText(msg.getContent());}else if (msg.getType() == Msg.TYPE_SENT){holder.rightLayout.setVisibility(View.VISIBLE);holder.leftLayout.setVisibility(View.GONE);holder.rightMsg.setText(msg.getContent());}}@Overridepublic int getItemCount() {return mMsgList.size();}
}

ChatActivity.java

在包内创建一个名为ChatActivity的Java类文件

public class ChatActivity extends AppCompatActivity {private Handler mHandler = new Handler();private List<Msg> msgList = new ArrayList<>();private EditText inputText;private Button send;private RecyclerView msgRecyclerView;private MsgAdapter adapter;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_chat);//设置返回按钮Button back = (Button) findViewById(R.id.weixin_back) ;back.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {finish();}});//聊天功能inintMsgs();inputText = (EditText) findViewById(R.id.input_txt);send = (Button) findViewById(R.id.btn_send);msgRecyclerView = (RecyclerView) findViewById(R.id.msg_recycler_view);LinearLayoutManager layoutManager = new LinearLayoutManager(this);msgRecyclerView.setLayoutManager(layoutManager);adapter = new MsgAdapter(msgList);msgRecyclerView.setAdapter(adapter);send.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {String content = inputText.getText().toString();if (!"".equals(content)){Msg msg = new Msg(content,Msg.TYPE_SENT);msgList.add(msg);adapter.notifyItemInserted(msgList.size() - 1);msgRecyclerView.scrollToPosition(msgList.size() - 1);inputText.setText("");recrive();}else {Toast.makeText(ChatActivity.this,"请输入",Toast.LENGTH_SHORT).show();}}});}private void inintMsgs() {Msg msg1 = new Msg("Hello",Msg.TYPE_RECEIVED);msgList.add(msg1);Msg msg2 = new Msg("nmsl",Msg.TYPE_SENT);msgList.add(msg2);Msg msg3 = new Msg("long may the sunshine!",Msg.TYPE_RECEIVED);msgList.add(msg3);}private void recrive(){Msg msg1 = new Msg("you are dragon,more dragon than me",Msg.TYPE_RECEIVED);msgList.add(msg1);}
}

朋友圈功能的实现

activity_pyquan.xml

在layout文件夹中创建一个名为activity_pyquan的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="#ffffff"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:background="#f2f2f2"><Buttonandroid:id="@+id/pyquan_back"android:layout_width="40dp"android:layout_height="40dp"android:layout_alignParentLeft="true"android:layout_marginLeft="10dp"android:layout_marginTop="12dp"android:background="@mipmap/back" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="朋友圈"android:textSize="25dp"android:textColor="#000000"android:layout_centerHorizontal="true"android:layout_marginTop="15dp"/><Buttonandroid:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/zhaoxiang"android:layout_alignParentRight="true"android:layout_marginTop="12dp"android:layout_marginRight="10dp"/></RelativeLayout><ListViewandroid:id="@+id/pyquan_listview"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#ffffff"android:overScrollMode="never"/>
</LinearLayout>

pyquan_content_item.xml

在layout文件夹中创建一个名为pyquan_content_item的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns: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:orientation="vertical"tools:ignore="MissingDefaultResource"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_marginBottom="5dp"><!--头像--><ImageViewandroid:id="@+id/pyquan_touxiang"android:layout_width="60dp"android:layout_height="60dp"android:background="@mipmap/touxiang"android:layout_marginLeft="15dp"android:layout_marginTop="15dp"/><!--内容--><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:layout_marginLeft="10dp"><TextViewandroid:id="@+id/pyquan_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="所长的肚子"android:textSize="20sp"android:textColor="#2999ce"android:layout_marginTop="15dp"/><TextViewandroid:id="@+id/pyquan_txt"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="所若干黑色和人格拉尔感觉到开发了的概率较大了开长大ad管理卡带回来卡迪夫辣豆腐静安寺电话费拉收到货了咖啡机阿拉斯加代理费"android:textSize="17dp"android:textColor="#000000"/><ImageViewandroid:id="@+id/pyquan_peitu"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@mipmap/photo"android:layout_marginTop="5dp"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="5dp"><TextViewandroid:id="@+id/pyquan_time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="2"android:textColor="#b5b5b5"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/pyquan_time"android:text="小时前"android:textColor="#b5b5b5"/><ImageViewandroid:layout_width="40dp"android:layout_height="20dp"android:background="@mipmap/dian"android:layout_alignParentRight="true"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout></LinearLayout>
</LinearLayout>

Pyquan.java

在entity文件夹中创建一个名为Pyquan的Java类文件

public class Pyquan {private String name;private String txt;private String time;private int imageId1;private int imageId2;public String getName() {return name;}public void setName(String name) {this.name = name;}public String getTxt() {return txt;}public void setTxt(String txt) {this.txt = txt;}public String getTime() {return time;}public void setTime(String time) {this.time = time;}public int getImageId1() {return imageId1;}public void setImageId1(int imageId1) {this.imageId1 = imageId1;}public int getImageId2() {return imageId2;}public void setImageId2(int imageId2) {this.imageId2 = imageId2;}
}

PyquanAdapter.java

在adapter文件夹中创建一个名为PyquanAdapter的Java类文件

public class PyquanAdapter extends ArrayAdapter<Pyquan> {private int resourceId;private static final String TAG = "PyquanAdapter";private List<Pyquan> list;public PyquanAdapter(@NonNull Context context, int resource, @NonNull List<Pyquan> objects) {super(context, resource, objects);resourceId = resource;}@NonNull@Overridepublic View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){Pyquan pyquan = getItem(position);View view = LayoutInflater.from(getContext()).inflate(resourceId,parent, false);ImageView touxiang = view.findViewById(R.id.pyquan_touxiang);TextView mingcheng = view.findViewById(R.id.pyquan_name);TextView neirong = view.findViewById(R.id.pyquan_txt);TextView time = view.findViewById(R.id.pyquan_time);ImageView peitu = view.findViewById(R.id.pyquan_peitu);touxiang.setImageResource(pyquan.getImageId1());peitu.setImageResource(pyquan.getImageId2());mingcheng.setText(pyquan.getName());neirong.setText(pyquan.getTxt());time.setText(pyquan.getTime());return view;}
}

PyquanActivity.java

在包内创建一个名为PyquanActivity的Java类文件

public class PyquanActivity extends AppCompatActivity {private List<Pyquan> pyquanList = new ArrayList<>();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_pyquan);//设置back按钮Button back = (Button) findViewById(R.id.pyquan_back) ;back.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {finish();}});inints();PyquanAdapter adapter = new PyquanAdapter(getApplicationContext(),R.layout.pyquan_content_item,pyquanList);ListView listView = findViewById(R.id.pyquan_listview);listView.setAdapter(adapter);}private void inints() {Pyquan p1 = new Pyquan();p1.setImageId1(R.mipmap.touxiang);p1.setImageId2(R.mipmap.photo);p1.setName("所长的肚子");p1.setTxt("所长的肚子所长的肚子所长的肚子所长的牛子所长的肚子所长的肚子所长的肚子所长的肚子");p1.setTime("2");pyquanList.add(p1);Pyquan p2 = new Pyquan();p2.setImageId1(R.mipmap.t_tx05);p2.setImageId2(R.mipmap.py02);p2.setName("Mr_Quin");p2.setTxt("分享图片");p2.setTime("5");pyquanList.add(p2);Pyquan p3 = new Pyquan();p3.setImageId1(R.mipmap.tx_kenny);p3.setImageId2(R.mipmap.py03);p3.setName("机智的肯尼");p3.setTxt("9494");p3.setTime("6");pyquanList.add(p3);Pyquan p4 = new Pyquan();p4.setImageId1(R.mipmap.t_tx04);p4.setImageId2(R.mipmap.py05);p4.setName("是acc啦");p4.setTxt("歇了");p4.setTime("7");pyquanList.add(p4);Pyquan p5 = new Pyquan();p5.setImageId1(R.mipmap.t_tx05);p5.setImageId2(R.mipmap.py04);p5.setName("Mr_Quin");p5.setTxt("都怪小樱");p5.setTime("8");pyquanList.add(p5);Pyquan p6 = new Pyquan();p6.setImageId1(R.mipmap.t_tx01);p6.setImageId2(R.mipmap.py06);p6.setName("笨笨");p6.setTxt("不列颠传说中的王。也被誉为骑士王。阿尔托莉雅是幼名,自从当上国王之后,就开始被称为亚瑟王了。在骑士道凋零的时代,手持圣剑,给不列颠带来了短暂的和平与最后的繁荣。史实上虽为男性,但在这个世界内却似乎是男装丽人。");p6.setTime("9");pyquanList.add(p6);}}

工程文件

这是这整个工程的文件,需要的话可以通过积分下载。

用AndroidStudio制作微信的界面-Android文档类资源-CSDN下载这是一个我用AndroidStudio模仿制作微信界面的工程文件的压缩包更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/nazonomaster/85232385

Android Studio 制作微信界面 下相关推荐

  1. Android Studio 制作微信界面 上

    工程功能介绍 打开app,首先是个闪屏界面(常见于一般打开app时的小广告),设置时间为2s后进入登录界面.在登录界面中,中间可以输入密码,点击登录按钮进入微信的界面.   微信的界面由4个fragm ...

  2. android studio微信界面设计,android studio开发微信界面

    android studio开发微信界面 android studio开发微信界面 功能说明:主要是做微信的简单的聊天界面,利用Fragment,进行微信界面的跳转 项目代码: 源代码地址 MainA ...

  3. Android Studio——类微信界面设计

    设计目标:Android studio制作简易类微信界面. 功能:展示四个可切换界面,当点击下方按钮时,界面随之切换. 布局:顶部和底部layout.主页面(中间放一个framelayout显示界面内 ...

  4. Android Studio 类微信界面的制作

    设计目标 使用Android Studio完成类微信的门户页面框架设计,APP包含4个tab页面.框架设计使用fragment,activity. 功能说明 界面的样式和微信打开后的界面相似 1点击底 ...

  5. 安卓移动开发实验:Android Studio设计微信界面

    一.实验的目的 通过使用Android Studio的Fragment和layout,来实现简单的微信界面切换. 二.app的功能 能够通过应用底部的bottom来实现四个页面的来回切换. 三.实验过 ...

  6. android studio开发微信界面

    微信界面 主要是做微信的简单的聊天界面,利用Fragment,进行微信界面的跳转 项目代码: 源代码 微信界面 图片: 这是我们要做的界面主要分为头部(top.xml)文件,底部(bottom.xml ...

  7. Android Studio类微信界面设计

    文章目录 一.类微信界面能实现的功能 二.xml代码 top.xml bottom.xml tab.xml activity_main.xml 三.Java代码 MainActivity.java w ...

  8. Android Studio 开发–微信APP门户界面设计

    Android Studio 开发–微信APP门户界面设计 本次Github代码仓库 --crcr1013/MyWechat 文章目录 Android Studio 开发--微信APP门户界面设计 前 ...

  9. 蓝牙聊天App设计1:Android Studio制作蓝牙聊天通讯软件(UI界面设计)

    前言:蓝牙聊天App设计全部有三篇文章(一.UI界面设计,二.蓝牙搜索配对连接实现,三.蓝牙连接聊天),这篇文章是一.UI界面设计 课程1:Android Studio小白安装教程,以及第一个Andr ...

最新文章

  1. linux 系统崩溃完全没有操作空间的系统修复
  2. Linux下制作和使用静态库和动态库
  3. centos 程序 mysql数据库文件位置,CentOS 更改MySQL数据库目录位置
  4. iOS-可变参数(不定参数)的用法
  5. arduino光敏+LED+数码管+蜂鸣器综合实验
  6. 使用静态工厂方法而不是构造器
  7. 解决http://localhost:3000/favicon.ico 的404 问题(含案例解析)
  8. Android自定义view之ViewPager指示器——2
  9. python入门_老男孩_数据类型简介_int/bool/str转换_字符串索引和切片_字符串操作_day3...
  10. JavaScript+cesium 添加高德影像图和标注
  11. oracle读取blob字段的方法,如何读取Oracle的BLOB字段里的文件?
  12. SIFI尺度不变特征变换算法
  13. java jnlp 运行_jnlp——通过浏览器直接执行java应用程序
  14. Linux内核启动去掉企鹅,linux更换启动时的小企鹅图片
  15. 意向性:或如何将之安置在自然界
  16. 计算机的硬盘就是内存不足,电脑内存不够用加内存条还是固态硬盘_电脑内存不够解决方法 - 系统家园...
  17. pandas 终极版1:创建和查看DataFrame数据 mysql读取数据
  18. 超详细!个人网盘搭建教程
  19. OFweek 2019 智能网联汽车发展高峰论坛在深圆满落幕!
  20. 【知识小记】Word转化为高清PDF

热门文章

  1. Tektronix P5205A/泰克P5205A差分探头
  2. 系统代理在注册表中的位置
  3. Android短信中的Contacts类
  4. 前端笔记87——clearTimeout
  5. for循环中使用settimeout和清除clearTimeout
  6. 联想拯救者R7000安装ubuntu20.04,解决GTX1650驱动问题
  7. python爬取指定关键字图片
  8. 成果推广规章制度体系包括哪些部分
  9. 高性能Web应用打造攻略:扩展过程中20个最大的绊脚石
  10. 安防IT化不得不看的关键技术