第七周(1) 后台代码编写、客户端具体功能实现与界面优化

来源:互联网 发布:炉石主播 知乎 编辑:程序博客网 时间:2024/06/05 09:40

引言

在这半周的工作中,我们小组仍然主要进行后台客户端的代码编写工作以及界面的优化,在这里,我对自己主要从事的工作,即查看评论功能,做一个重点的介绍。

一、界面编写

在之前的界面设计中,已经完成了关于我们界面的设计。该界面比较简单,在最外层使用一个纵向的LinearLayout,内层嵌套一个ListView显示列表即可,具体代码如下所示:

<?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">    <RelativeLayout        android:layout_width="match_parent"        android:layout_height="?attr/actionBarSize"        android:background="@color/white"        android:padding="0dp">        <ImageButton            android:layout_width="?attr/actionBarSize"            android:layout_height="?attr/actionBarSize"            android:layout_alignParentLeft="true"            android:background="@drawable/toolbar_back_bg"            android:onClick="CommentBack"            android:src="?attr/homeAsUpIndicator" />        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerInParent="true"            android:text="评论"            android:textColor="@color/black"            android:textSize="19sp" />    </RelativeLayout>    <ListView        android:id="@+id/comment_lv"        android:layout_width="match_parent"        android:layout_height="match_parent" /></LinearLayout>

根据该代码生成的预览效果如下所示,可以看到是符合预期的。
这里写图片描述

二、内部逻辑实现

功能十分简单,只需要从后台获取评论,然后加载到ListView中显示即可。
代码如下:

/** * 评论界面 */public class CommentActivity extends BaseActivity {    private ListView comment_lv;    private ArrayList<SuperViseBriefBean> SuperViseBriefList;    private CommentListAdapter adapter;    @Override    public int getLayoutId() {        return R.layout.activity_comment;    }    @Override    public void afterCreate(Bundle savedInstanceState) {        comment_lv = (ListView) findViewById(R.id.comment_lv);        Intent intent = getIntent();        SuperViseBriefList = (ArrayList<SuperViseBriefBean>) intent.getExtras().get("briefBean");        adapter = new CommentListAdapter(this, SuperViseBriefList);        comment_lv.setAdapter(adapter);    }    public void CommentBack(View view) {        CommentActivity.this.finish();    }}

功能完成之后,我进行了白盒测试。因为代码比较简单的缘故,测试没有发现问题,顺利通过。

阅读全文
0 0