我正在尝试将数据从一个页面传输到另一个页面,但下面的一些问题是代码.我试图使用捆绑从第一个活动转移到第二个变量的值,但有些错误请告诉我什么是错的.
以下是第一项活动: -
package route.planning;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class login extends Activity {
/** Called when the activity is first created. */
Context mCtx;
final static int START =0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mCtx = this;
Button btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener(){
// @Override
public void onClick(View v)
{
String fromLat = new String();
String fromLong = new String();
String toLat = …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,我想获得Android模拟器的UDID.我该怎么做?
提前谢谢,Tushar
我想将图像保存到我的本地驱动器文件夹或res/drawable我的应用程序中的文件夹.我现在正在将img保存到SD卡中,但我要将它保存在res/drawable文件夹中.我的代码是:
String image_URL = "http://chart.apis.google.com/chart?chs=200x200&cht=qr&chl=http%3A%2F%2Fandroid-er.blogspot.com%2F";
String extStorageDirectory;
Bitmap bm;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonSave = (Button) findViewById(R.id.save);
ImageView bmImage = (ImageView) findViewById(R.id.image);
BitmapFactory.Options bmOptions;
bmOptions = new BitmapFactory.Options();
bmOptions.inSampleSize = 1;
bm = LoadImage(image_URL, bmOptions);
bmImage.setImageBitmap(bm);
extStorageDirectory = Environment.getExternalStorageState().toString();
extStorageDirectory = Environment.getExternalStorageDirectory()
.toString();
buttonSave.setText("Save to " + extStorageDirectory + "/qr.PNG");
buttonSave.setOnClickListener(buttonSaveOnClickListener);
}
private Bitmap LoadImage(String URL, BitmapFactory.Options options) {
Bitmap bitmap = null;
InputStream …Run Code Online (Sandbox Code Playgroud) 我想在Android市场上设置Google商家帐户来销售我的应用.我是印度人,在国内下拉印度没有.如何创建我的商家帐户,我可以使用Paypal等其他帐户销售应用程序吗?
谢谢.
当我将Xml节点解组为属性时,将调用setMyProperty.属性setter的代码可能引发异常:在这种情况下会发生什么?
我观察到的行为:如果异常是未经检查的异常,那么jaxb"internals"会吞下它,并忽略该属性.如果在Exception中更改了RuntimeException(如此检查并添加到属性setter的throws子句),则会导致unmarshal失败.
问题是:这是一种你可以依赖的行为吗?在此感谢Agostino
PS:Ok"swallowed"不是正确的单词,因为它实际上是以"最佳方式"进行管理,正确地解组文档的其余部分.然而,unmarshall调用者不会被通知异常发生.
PS:一个简单的测试用例,以防万一:-)
package test.jaxb;
import java.io.File;
import javax.xml.bind.*;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class SZL {
public static void main(String [] args) throws JAXBException {
SZL test = new SZL();
test.myProp = "test-value";
test.setMyProp2("test-value-2");
JAXBContext jc = JAXBContext.newInstance(SZL.class);
File f = new File("SZL.xml");
Marshaller m = jc.createMarshaller();
m.marshal(test, f);
test = null;
Unmarshaller um = jc.createUnmarshaller();
test = (SZL)um.unmarshal(f);
System.out.println("The RuntimeException has been swallowed");
System.out.println(test.myProp);
System.out.println(test.myProp2);
}
private String myProp;
public void setMyProp(String myProp) {
throw new RuntimeException(); …Run Code Online (Sandbox Code Playgroud) 我希望查询不返回任何值.我不能不查询数据库,所以我想为谓词添加一些无法访问的条件,比如'where 1 <> 1'.但CriteriaBuilder.equal()不允许这样做.有没有办法达成目标?
谢谢.
我开始一个活动,我需要显示一个alertdialog,所以我写了一个对话框util类(dialoghandler),我将上下文传递给dialoghandler,第一次启动是好的,但是当我启动第二个时,它发生异常.我应该这样做,ps帮助我.
这是错误报告:
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): FATAL EXCEPTION: main
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.view.ViewRoot.setView(ViewRoot.java:509)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.app.Dialog.show(Dialog.java:241)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.update.EoeSdkUpdate.onCacheFetched(EoeSdkUpdate.java:170)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.net.CacheManager.handleCallBackMag(CacheManager.java:362)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.net.CacheManager.access$1(CacheManager.java:358)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at com.eoemobile.api.net.CacheManager$CallbackHandler.handleMessage(CacheManager.java:375)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.os.Looper.loop(Looper.java:123)
12-03 07:23:26.000: ERROR/AndroidRuntime(21525): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-03 …Run Code Online (Sandbox Code Playgroud) 我正在 android 2.2 中开发一个应用程序。
当更改设备方向(通过旋转设备)时,我的 Activity 边界会绘制一个黑屏(甚至没有 Activity 标题),这需要几秒钟(7-15 秒),然后最终绘制 Activity。
我已经测试了它模拟器和两个不同的设备,行为是相同的。
在 LogCat 我有下一个输出:
02-02 09:18:06.044: WARN/WindowManager(1300): MyActivity freeze timeout expired.
02-02 09:18:06.044: WARN/WindowManager(1300): Force clearing freeze: AppWindowToken{4515af88 token=HistoryRecord{44f52458 com.project.package/.MyActivity}}
02-02 09:18:08.054: WARN/WindowManager(1300): Window freeze timeout expired.
02-02 09:18:08.054: WARN/SurfaceFlinger(1300): timeout expired mFreezeDisplay=1, mFreezeCount=0
02-02 09:18:08.054: WARN/WindowManager(1300): Force clearing orientation change: Window{45178a00 com.project.package/com.project.package.Activity paused=false}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会这样。感谢您的评论,建议,答案。
很抱歉,如果这是一个常见的问题,但我不知道它叫什么,所以我在搜索它时遇到了麻烦.
这是如何运作的:
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Run Code Online (Sandbox Code Playgroud)
我明白这意味着视图获得灵活的宽度和高度,但它如何存储两个这样的变量?
如果我查看UIViewAutoresizing的typedef,它看起来像:
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
...
Run Code Online (Sandbox Code Playgroud)
那么,一个变量如何存储多个像这样的值呢?
android ×6
java ×3
criteria-api ×1
google-play ×1
hash ×1
image ×1
jaxb ×1
objective-c ×1
properties ×1
save ×1