編輯:關於Android編程
android傳遞對象有兩種方式:
一種是Serializable和Parcelable
對於第一種方式:
import java.io.Serializable;
public class ShopData implements Serializable {
public String shopId;
public String name;
public String url;
public String info;
public String getShopId() {
return shopId;
}
public void setShopId(String shopId) {
this.shopId = shopId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
}
傳遞值的時候這樣來傳遞:
Intent intent = new Intent(); ShopData shopData = (ShopData)mAdapter.getItem(position); // intent.putExtra("detail", shopData); Bundle bundle = new Bundle(); bundle.putSerializable("shop", shopData); intent.putExtra("detail", shopData); intent.setClass(MainActivity.this, DetailShopActivity.class); MainActivity.this.startActivity(intent);取值的時候:
Intent intent = getIntent(); // ShopData data = intent.getParcelableExtra("detail"); ShopData data = (ShopData)intent.getSerializableExtra("detail");
import android.os.Parcel; import android.os.Parcelable; public class ShopData implements Parcelable{ public String shopId; public String name; public String url; public String info; public ShopData(Parcel in) { readFromParcel(in); } public ShopData() { } public static final Parcelable.CreatorCREATOR = new Parcelable.Creator () { public ShopData createFromParcel( Parcel in ){ return new ShopData(in); } public ShopData[] newArray( int size){ return new ShopData[size]; } }; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(shopId); dest.writeString(name); dest.writeString(url); dest.writeString(info); } public void readFromParcel( Parcel in ){ shopId = in.readString(); name = in.readString(); url = in.readString(); info = in.readString(); } }
Intent intent = new Intent(); ShopData shopData = (ShopData)mAdapter.getItem(position); intent.putExtra("detail", shopData); intent.putExtra("detail", shopData); intent.setClass(MainActivity.this, DetailShopActivity.class); MainActivity.this.startActivity(intent);
Intent intent = getIntent(); ShopData data = intent.getParcelableExtra("detail");
FFBM: fast factory boot mode,快速工程啟動模式此函數主要是如何解析boot.img和recovery.img的頭部信息,提取這兩部分的參數,傳
手機屏幕怎麼看好壞?屏幕是否夠清晰?接下來小編將教教大家怎麼從分辨率去看手機屏幕的好壞,快來圍觀吧!手機屏幕怎麼看好壞?手機屏幕怎麼看好壞?你的手機屏幕分辨
前言: Android 4.4之後谷歌提供了沉浸式全屏體驗, 在沉浸式全屏模式下, 狀態欄、 虛擬按鍵動態隱藏, 應用可以使用完整的屏幕空間, 按
概述:前幾天突然需要做兩種圖表——柱形圖、折線圖,於是第一反應是先看看網上有沒有現成的,結果有是有,但都不是我想要的,而且大多數不是用純andro
關於Android View 事件分發過程的文章網絡上可以搜到一把大,這