精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2012-02-11
看了很多,总结以下首先activity1和activity2之间
activity1的时候 传值{ Intent intent = new Intent(); }
@Override }
activity2里面
protected void onCreate(Bundle savedInstanceState) {
返回传值的程序是 { Intent intent = new Intent(); }
加粗的那几个地方,需要注意!谢谢 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2012-02-15
两个activity之间的Intent 传值
A: intent.setClass(SoundListenActivity.this, appset.class); Bundle bundle =new Bundle(); bundle.putString("phonenum", phonenum); bundle.putLong("threhode", threhode); intent.putExtras(bundle); startActivity(intent); B: Bundle bundle =getIntent().getExtras(); String phonenum=bundle.getString("phonenum"); Long threhode=bundle.getLong("threhode"); System.out.println("appset-->>"+phonenum+">>"+threhode); 不就成了? 回调来回调去的.. |
|
返回顶楼 | |
发表时间:2012-02-15
能否传集合类型,之前试过一次,没成功。
|
|
返回顶楼 | |
发表时间:2012-02-16
若两个activity是在两不同的应用中,怎么传复杂对象?
实现Serializable或Parcelable好像不行 我现在的做法是将复杂对象base64转成字符串传 |
|
返回顶楼 | |
发表时间:2012-02-16
嗯,bundle传不了对象,是否可以调用个全局的class模块,我也没试过,等闲下来的时候试试,
|
|
返回顶楼 | |
发表时间:2012-02-17
阿浊I 写道 嗯,bundle传不了对象,是否可以调用个全局的class模块,我也没试过,等闲下来的时候试试,
"bundle传不了对象"这句话是不对的,我试过,intent是可以传List的,但List里面的数据多了会报错。 |
|
返回顶楼 | |
发表时间:2012-02-21
MarkJoker 写道 阿浊I 写道 嗯,bundle传不了对象,是否可以调用个全局的class模块,我也没试过,等闲下来的时候试试,
"bundle传不了对象"这句话是不对的,我试过,intent是可以传List的,但List里面的数据多了会报错。 好的,谢谢提出新的意见,等我空下来再看看,哈,谢谢,就是没顾上看那个开发文档,里面有详细的传值 boolean containsKey(String key) Returns true if the given key is contained in the mapping of this Bundle. int describeContents() Report the nature of this Parcelable's contents Object get(String key) Returns the entry with the given key as an object. boolean getBoolean(String key) Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key. boolean getBoolean(String key, boolean defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. boolean[] getBooleanArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. Bundle getBundle(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. byte getByte(String key) Returns the value associated with the given key, or (byte) 0 if no mapping of the desired type exists for the given key. Byte getByte(String key, byte defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. byte[] getByteArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. char getChar(String key) Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key. char getChar(String key, char defaultValue) Returns the value associated with the given key, or (char) 0 if no mapping of the desired type exists for the given key. char[] getCharArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. CharSequence getCharSequence(String key, CharSequence defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. CharSequence getCharSequence(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. CharSequence[] getCharSequenceArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. ArrayList<CharSequence> getCharSequenceArrayList(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. ClassLoader getClassLoader() Return the ClassLoader currently associated with this Bundle. double getDouble(String key) Returns the value associated with the given key, or 0.0 if no mapping of the desired type exists for the given key. double getDouble(String key, double defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. double[] getDoubleArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. float getFloat(String key) Returns the value associated with the given key, or 0.0f if no mapping of the desired type exists for the given key. float getFloat(String key, float defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. float[] getFloatArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. int getInt(String key, int defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. int getInt(String key) Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key. int[] getIntArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. ArrayList<Integer> getIntegerArrayList(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. long getLong(String key) Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key. long getLong(String key, long defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. long[] getLongArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. <T extends Parcelable> T getParcelable(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. Parcelable[] getParcelableArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. <T extends Parcelable> ArrayList<T> getParcelableArrayList(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. Serializable getSerializable(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. short getShort(String key) Returns the value associated with the given key, or (short) 0 if no mapping of the desired type exists for the given key. short getShort(String key, short defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. short[] getShortArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. <T extends Parcelable> SparseArray<T> getSparseParcelableArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. String getString(String key, String defaultValue) Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. String getString(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. String[] getStringArray(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. ArrayList<String> getStringArrayList(String key) Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key. boolean hasFileDescriptors() Reports whether the bundle contains any parcelled file descriptors. boolean isEmpty() Returns true if the mapping of this Bundle is empty, false otherwise. Set<String> keySet() Returns a Set containing the Strings used as keys in this Bundle. |
|
返回顶楼 | |
浏览 6803 次