"晴天"天气app的开源库逐步学习(四)
来源:互联网 发布:淘宝买发票怎么搜 编辑:程序博客网 时间:2024/05/17 01:01
今天尝试了JazzyListView和之前介绍的ShimmerTextView这两个开源库。
JazzyListView地址:https://github.com/twotoasters/JazzyListView
ShimmerTextView地址:https://github.com/RomainPiel/Shimmer-android
原来的app使用这个androidannotations框架(上一期我介绍过),所以代码都不是和我们初学的一样,不过我自己是用我们最基础的语法写的,也就是setContenView,findViewById等等等
效果如下:
上一张是我自己做的,第二张是原来app的效果,为什么我没有第二列和第三列呢,因为我没联网获取==,反正效果到了就好==。
贴代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.sdf.jazzylistviewdemo"
android:id="@+id/cityLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/list_bg"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/top_box" >
<com.sdf.jazzylistviewdemo.romainpiel.shimmer.ShimmerTextView
android:id="@+id/currentCityTxt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center_vertical"
android:textColor="@color/white"
android:textSize="20sp"
android:text="城市"
app:reflectionColor="@color/list_bg" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/white" />
<LinearLayout
android:id="@+id/selectCity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:id="@+id/cityTitle"
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@color/list_bg"
android:orientation="horizontal"
android:visibility="gone" >
<TextView
android:id="@+id/c1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableRight="@drawable/right"
android:gravity="center"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/c2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableRight="@drawable/right"
android:gravity="center"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/c3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/cityContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/list_bg"
android:orientation="horizontal"
android:paddingTop="1dp" >
<com.sdf.jazzylistviewdemo.widget.jazzylistview.JazzyListView
android:id="@+id/listProvince"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/shape_city_bg"
android:scrollbars="none"
app:effect="helix"
app:max_velocity="0"
app:only_animate_fling="false"
app:only_animate_new_items="false" />
<com.sdf.jazzylistviewdemo.widget.jazzylistview.JazzyListView
android:id="@+id/listCity"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/shape_city_bg"
android:scrollbars="none"
android:visibility="gone"
app:effect="helix"
app:max_velocity="0"
app:only_animate_fling="false"
app:only_animate_new_items="false" />
<com.sdf.jazzylistviewdemo.widget.jazzylistview.JazzyListView
android:id="@+id/listTown"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/shape_city_bg"
android:scrollbars="none"
android:visibility="gone"
app:effect="helix"
app:max_velocity="0"
app:only_animate_fling="false"
app:only_animate_new_items="false" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Java代码(只放一部分,太多了==):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initId();
addContentAnim();
viewInit();
toggleCity();
getCityList("province", "", "loadProvince");
mListViewProvince.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
City city = (City) mListViewProvince
.getItemAtPosition(position);
getCityList("city", city.getCityId(), "loadCity");
mLayoutCityTitle.setVisibility(View.VISIBLE);
c1.setText(city.getCityName());
adapterTown.clear();
c2.setVisibility(View.INVISIBLE);
mListViewCity.setVisibility(View.VISIBLE);
mListViewTown.setVisibility(View.GONE);
c2.setText("");
c3.setText("");
}
});
mListViewCity.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
City city = (City) mListViewCity.getItemAtPosition(position);
getCityList("town", city.getCityId(), "loadTown");
c2.setVisibility(View.VISIBLE);
mListViewTown.setVisibility(View.VISIBLE);
c2.setText(city.getCityName());
c3.setText("");
}
});
mListViewTown.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
City city = (City) mListViewTown.getItemAtPosition(position);
c3.setText(city.getCityName());
currentCity = city;
}
});
}
博主自己也是个菜鸟,不会做的很好0.0
我的例子的源码http://download.csdn.net/detail/u011388551/8761891
- "晴天"天气app的开源库逐步学习(四)
- "晴天"天气app的开源库逐步学习(一)
- "晴天"天气app的开源库逐步学习(二)
- "晴天"天气app的开源库逐步学习(三)
- "晴天"天气app的开源库逐步学习(五)完结篇
- #趣米杯#码农天气--码农自己的天气APP(四)
- Android 端天气预报APP的实现(四)使用ViewPager展示天气数据
- RxAndroid 应用(四)(简易天气App之RxBus)
- LibSVM学习(四)——逐步深入LibSVM
- LibSVM学习(四)——逐步深入LibSVM
- LibSVM学习(四)——逐步深入LibSVM
- LibSVM学习(四)——逐步深入LibSVM
- LibSVM学习(四)——逐步深入LibSVM
- 天气APP的实战(1)
- android学习笔记——天气APP的尝试
- 基于Android的天气APP
- 高仿墨迹天气 白天晴天
- #趣米杯#码农天气--码农自己的天气APP(一)
- 用Python和Pygame写游戏-从入门到精通(2)
- 缩略图缓存清除(仅win7)
- Android Service
- wireshark 卡死,不能运行,进度显示100%,"Loading configuration files 的解决办法
- 算法学习(Java实现之字符串篇)····二进制求和
- "晴天"天气app的开源库逐步学习(四)
- 一个JAVA面试题
- 异常
- Gallery 实现图片逐一展示 和 显示当前图片张数
- UVA - 12470 Tribonacci 矩阵快速幂
- 真正的轻量级WebService框架——使用JAX-WS(JWS)发布WebService
- 明源售楼系统技术解析 销售控制(更名查询与变更查询)
- RAC下启动日志归档模式
- 某文件的权限为d-rw-_r--_r--,用数值形式表示该权限,则八进制数为644,文件属性为目录,为什么呢?(最近在复习linux,明天考试, 今天先总结下)