編輯:關於Android編程
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); if (intent != null) { Parcelable p = intent.getParcelableExtra(info); if (p != null) { System.out.println(p); } } } @Override protected void onDestroy() { super.onDestroy(); } public void start(View view) { Intent intent = new Intent(getApplicationContext(), MainActivity.class); intent.putExtra(info, new Bean(100, baidu)); startActivity(intent); } }
import android.os.Parcel; import android.os.Parcelable; public class Bean implements Parcelable { int age; String name; public Bean(int age, String name) { this.age = age; this.name = name; } @Override public int describeContents() { // return 0; } @Override public void writeToParcel(Parcel dest, int flags) { //向dest容器中寫入數據,int占4個字節,至於區分String應該有特殊的標志位,相當於反序列化 dest.writeInt(this.age); dest.writeString(this.name); } public static final Parcelable.CreatorCREATOR = new Parcelable.Creator () { @Override public Bean createFromParcel(Parcel source) { //按照順序從source中解析出數據,相當於序列化 int age = source.readInt(); String name = source.readString(); return new Bean(age, name); } @Override public Bean[] newArray(int size) { return new Bean[size]; } }; @Override public String toString() { return Bean [age= + age + , name= + name + ]; } }
簡介類別:項目文檔生成器,生成靜態站點,管理MarkDown文檔。官方網址:http://www.mkdocs.org/中文文檔:http://markdown-docs
記得淘寶裡面買家給賣家評分的時候會有一個星星狀的評分條,其實就是基於RatingBar做了自定義使用了。那麼本篇文章就對RatingBar的使用做一個基本的認識。接下來就
Service概念及用途A service is an application component that can perform long-running opera
照片牆這種功能現在應該算是挺常見了,在很多應用中你都可以經常看到照片牆的身影。它的設計思路其實也非常簡單,用一個GridView控件當作“牆”,然