android拨号界面代码_人人都可写代码-Android零基础编程-热文榜界面实操06

欢迎来到人人都可写代码,大家好,我是杨晓华,今天我们的课程内容是项目实操,以智者精选项目为例,开发一个Android的热文榜界面。

这是要实现的热文榜界面展示效果,下面就是教大家如何制作的步骤:

23b12597d1771d5a80561dd0abde89c5.png
  1. 热文榜界面因为是框架的一级页面,所以把它设计为Fragment,而不是Activity;在Fragment目录里首先创建一个ReWenFragment,然后在res目录的layout里创建一个activity_rewen_bang.xml,最后是在Fragment文件里关联布局文件XML和关联数据接口。

2、activity_rewen_bang.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:background="@color/background" android:orientation="vertical">
<include layout="@layout/activity_default_title" />
<RadioGroup android:background="@color/white" android:id="@+id/radio_group" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="40dp">
<RadioButton android:id="@+id/rb_ri_pai_hang" android:text="日排行" style="@style/content_rb_style"
/>
<RadioButton android:id="@+id/rb_zhou_pai_hang" android:text="周排行" style="@style/content_rb_style"
/>
</RadioGroup>
<View android:id="@+id/view_split" android:layout_width="match_parent" android:layout_height="1px" android:layout_alignParentBottom="true" android:background="#66000000" />
<LinearLayout android:id="@+id/ll_bottom" android:layout_width="match_parent" android:layout_height="2dip" android:layout_alignParentBottom="true" android:orientation="horizontal">
<View android:id="@+id/view_bottom_line" android:layout_width="wrap_content" android:layout_height="2dip" android:background="@color/light_blue" />
</LinearLayout>
<ListView android:id="@+id/essay_listview" android:layout_width="fill_parent" android:layout_height="match_parent" android:scrollbars="none">
</ListView>
</LinearLayout>

3、ReWenFragment文件关联activity_rewen_bang.xml布局文件的部分代码是:

@Overridepublic View initSuccessView() {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.activity_rewen_bang, null);
ButterKnife.bind(this, view);
initView();return view;
}

4、ReWenFragment文件关联数据接口, activity_rewen_bang.xml布局文件的控件绑定数据接口,并展示数据的部分代码是:

private void loadData() {
showLoadingDialog();
String url;if(posLog == 0)
{
url = Config.Url.DAY_ESSAY_LIST_URL;
}else
{
url = Config.Url.WEEK_ESSAY_LIST_URL;
}
Map<String, String> params = new HashMap<>();
params.put("appid", Config.Url.APP_ID + "");
OkHttpClientManager.postAsyn(url, new OkHttpClientManager.ResultCallback<EssayListBean>() {
@Overridepublic void onError(Request request, Exception e) {
closeLoadingDialog();
Toast.makeText(UIUtils.getContext(), "网络不给力哦!,请稍试!", Toast.LENGTH_SHORT).show();
showError();
}
@Overridepublic void onResponse(EssayListBean response) {
closeLoadingDialog();mEssayListBean = response;mData = mEssayListBean.getData();essayListview.setAdapter(new EssayListAdapter(mData));
}
}, params);
}

以上几个步骤,是实现热文榜界面逻辑的整体思路,可以按照这个思路去多练习,具体的全部代码请参考我提供的开发框架源码。

开头:人人都可写代码-Android零基础编程-序言-01

下一篇:人人都可写代码-Android零基础编程-我的界面实操07

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值