jamendo笔记

一、开机启动页面SplashscreenActivity


启动页面很简单,总共就这么几个成员变量.效果为,Activity先setContentView,然后延迟2秒后,当前页面渐变动画,动画消失后,启动HomePage.

所谓的渐变效果的实现过程实际上是,Coding时先不考虑动画效果,先把静态的做出来,当静态的做好时,在把动画加上去。

二、HomeActivity



如图所示,主页面分两部分,上方为ViewFlipper,下方则是一个listview

1、ViewFliper

<com.teleca.jamendo.util.FixedViewFlipper
		android:orientation="vertical" android:id="@+id/ViewFlipper"
		android:layout_width="fill_parent" android:layout_height="75dip"
		android:background="@drawable/gradient_dark_purple">

		<!-- (0) Loading -->
		<LinearLayout android:orientation="vertical"
			android:layout_width="fill_parent" android:layout_height="fill_parent"
			android:layout_marginLeft="15dip" android:gravity="left|center_vertical">
			<com.teleca.jamendo.widget.ProgressBar
				android:id="@+id/ProgressBar" android:layout_width="wrap_content"
				android:layout_height="wrap_content">
			</com.teleca.jamendo.widget.ProgressBar>
		</LinearLayout>

		<!-- (1) Gallery -->
		<LinearLayout android:orientation="vertical"
			android:layout_width="fill_parent" android:layout_height="fill_parent"
			android:gravity="center">
			<Gallery android:id="@+id/Gallery" android:layout_width="fill_parent"
				android:layout_height="wrap_content" android:spacing="0px" />
		</LinearLayout>

		<!-- (2) Failure -->
		<LinearLayout android:orientation="vertical"
			android:layout_width="fill_parent" android:layout_height="fill_parent"
			android:layout_marginLeft="15dip" android:gravity="left|center_vertical">
			<com.teleca.jamendo.widget.FailureBar
				android:id="@+id/FailureBar" android:layout_width="wrap_content"
				android:layout_height="wrap_content">
			</com.teleca.jamendo.widget.FailureBar>
		</LinearLayout>
	</com.teleca.jamendo.util.FixedViewFlipper>
注意!ViewFlipper在android2.1以上版本存在BUG,需要自己重载重新写一个类,重载onDetachedFromWindow即可。
@Override

	protected void onDetachedFromWindow() {

		int apiLevel = Build.VERSION.SDK_INT;

		if (apiLevel >= 7) {
			try {
				super.onDetachedFromWindow();
			} catch (IllegalArgumentException e) {
				Log.w("Jamendo", "Android project  issue 6191  workaround.");
				/* Quick catch and continue on api level 7, the Eclair 2.1 */
			} finally {
				super.stopFlipping();
			}
		} else {
			super.onDetachedFromWindow();
		}
	}

ViewFlipper的xml写法如上所示,在代码中可以 mViewFlipper.setDisplayedChild(0);来控制显示哪一个,本身为互斥的。
2.ListView
<android.gesture.GestureOverlayView
		xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gestures"
		android:layout_width="fill_parent" android:layout_height="fill_parent"

		android:gestureStrokeType="multiple"
		android:eventsInterceptionEnabled="false" android:orientation="vertical">

		<ListView android:id="@+id/HomeListView"
			android:layout_width="fill_parent" android:layout_height="fill_parent"
			android:divider="#000" />
	</android.gesture.GestureOverlayView>
由于需求为在主页面支持手势,故需要上述布局。
<com.teleca.jamendo.widget.ProgressBar
为一个Linearlayout,其中包括一个ProgressBar和一个TextView,采用inflate的方式将layout.xml合进来。
同理,
com.teleca.jamendo.widget.FailureBar也是一样。
3.代码部分

3.1 launch方法,这样写的好处是,在任何一个地方启动该页面都是用的同一个flag,不会存在其他的变数,便于统一管理

一个应用的HomePage页面,启动的flag一定要设置为CLEAR_TOP!因为在主页时,按返回键是不可以在回到其他页面的。

public static void launch(Context c) {
		Log.i(TAG, "============================HomeActivity launch!");
		Intent intent = new Intent(c, HomeActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		c.startActivity(intent);
	}
3.2OnCreate方法

此时,VIEW已经做好,需要加上Controler,在OnCreate中findAllViewById之后,变启动了一个asyncTask来获取并显示最新上线的专辑,取得数据

3.3OnResume方法

在这里显示主页面的ListView

这个ListView的adapter比较特殊。如图所以,中间有两行是不可以点击的,只是显示用的。乍一看是两个ListView,而实际上是一个。



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值