Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。

15
如何在FlatButton单击时关闭AlertDialog?
我有以下几点AlertDialog。 showDialog( context: context, child: new AlertDialog( title: const Text("Location disabled"), content: const Text( """ Location is disabled on this device. Please enable it and try again. """), actions: [ new FlatButton( child: const Text("Ok"), onPressed: _dismissDialog, ), ], ), ); 我_dismissDialog()该如何解雇说AlertDialog?




15
Android TextView大纲文本
有一种简单的方法可以使文本具有黑色轮廓吗?我的文本视图将使用不同的颜色,但是某些颜色无法很好地显示在我的背景中,所以我想知道是否有一种简单的方法来获得黑色轮廓或其他可以完成此工作的方法?我希望不必创建自定义视图并制作画布等。

8
应用程序未连接到计算机时,为什么要等待调试器?
似乎我在Android世界中迈出的每一步都遇到了问题。 通常,我的HTC Hero通过USB连接到计算机,然后以调试模式或普通模式启动应用程序。 因此,我上次在正常模式下运行该应用程序。然后,我断开设备连接(我想尝试使其“免费”,而不是连接到计算机),然后从菜单启动该应用程序。当我这样做时,我会弹出一个窗口,说“应用程序xxx正在等待调试器附加”,然后它停止并最终死亡。 为什么当我上次运行应用程序(连接时)没有将其作为调试程序运行时,它为什么要等待调试器? 编辑1 我可能会添加一个奇怪的事实: 如果在连接设备时执行“运行”(绿色/白色箭头),则设备上仍会弹出一个窗口,提示“应用程序xxx正在等待调试器连接”。 编辑2 找到此页面。他重新启动了设备,这对我也有用。愚蠢的不要马上尝试...
82 android 

11
多个按钮的OnClickListener()android
我目前正在Android上制作一个简单的计算器应用程序。我试图设置代码,以便当按下数字按钮时,它将使用该数字更新计算器屏幕。目前,我正在这样做。 Button one = (Button) findViewById(R.id.oneButton); one.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView output = (TextView) findViewById(R.id.output); output.append("1"); } }); 它可以工作,但我正在为计算器上的每个按钮编写相同的代码。可以想象,这是非常多余的。无论如何,我可以以更有效的方式编写此代码吗?一个涉及不为每个按钮编写此方法的方法?

8
当视图可见性为View.GONE时RelativeLayout出现问题
我RelativeLayout这样: <RelativeLayout> <TextView1/> <TextView2/> // <-- View.VISIBLE OR View.GONE <TextView3/> <TextView4/> </RelativeLayout> 每个TextView锚定跌破前期TextView用android:layout_below。 问题在于TextView2可能存在或可能不存在(View.VISIBLE或View.GONE);如果为View.VISIBLE,则表示一切正常,但如果为View.GONE,则TextView3最终呈现在TextView1的顶部。 我尝试了各种方法来解决此问题,但是每次都被RelativeLayout“'在定义ID之前不能引用它”规则所困扰。 我希望这里缺少明显的东西。

11
如何将新列添加到Android SQLite数据库?
我对AndroidSQLite数据库有一个问题。 我有一个包含一个字段的表.StudentFname并且该应用程序在Android 2.3.1上运行良好,现在如果我添加另一个字段,则我的应用程序无法正常运行。 谁能帮助我非常了解数据库的我,

9
Android:API级VS。Android版
我是Android开发的新手,我想知道版本和API级别之间的联系或区别是什么。每个人指的是什么?当我决定为API 14或Android 4.0开发某些应用程序时,这意味着什么? 还是一个是另一个的子集?我根本没有区别,为什么会有两个柜台? 谢谢
82 android 


4
如何按名称从res / raw读取文件
我想从文件夹res / raw /中打开一个文件。我绝对确定该文件存在。打开我尝试过的文件 File ddd = new File("res/raw/example.png"); 命令 ddd.exists(); 产生FALSE。因此,此方法不起作用。 试 MyContext.getAssets().open("example.png"); 最终以getMessage()“ null”出现异常。 只需使用 R.raw.example 这是不可能的,因为文件名仅在运行时称为字符串。 为什么访问/ res / raw /文件夹中的文件如此困难?

1
gradle的依赖图中“->”(箭头)是什么意思?
我正在尝试运行一些Android测试,但是,编译器抱怨存在多个dex文件。 Multiple dex files define Lorg/hamcrest/MatcherAssert; 所以我试图过滤重复的依赖项: $ ./gradlew -q dependencies app:dependencies --configuration androidTestCompile 但是我得到以下输出: ------------------------------------------------------------ Project :app ------------------------------------------------------------ androidTestCompile - Classpath for compiling the androidTest sources. +--- org.mockito:mockito-core:1.9.5 | +--- org.hamcrest:hamcrest-core:1.1 -> 1.3 | \--- org.objenesis:objenesis:1.0 -> 2.1 +--- com.google.dexmaker:dexmaker-mockito:1.2 | +--- com.google.dexmaker:dexmaker:1.2 | \--- org.mockito:mockito-core:1.9.5 (*) +--- com.android.support.test.espresso:espresso-core:2.0 …

7
如何在上传到服务器之前减小图像文件的大小
许多应用程序允许共享从图库中选取的图像。 他们是否上传原始图像文件?哪怕是1-3 mb?还是他们处理? 无论如何,我如何从文件路径中获取图像,通过降低分辨率来减小其大小,然后将其保存在其他位置并尝试上传? 我试过了: Bitmap photo = decodeSampledBitmapFromFile(filePath, DESIRED_WIDTH, DESIRED_HEIGHT); FileOutputStream out = new FileOutputStream(filePath); photo.compress(Bitmap.CompressFormat.JPEG, 100, out); public static Bitmap decodeSampledBitmapFromFile(String path, int reqWidth, int reqHeight) { final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); final int height = options.outHeight; final int width = options.outWidth; …
82 android  image  upload 

10
如何在翻新中处理动态JSON?
我正在使用改造高效的网络库,但是无法处理包含单个前缀的Dynamic JSON,该前缀 responseMessage会object随机responseMessage更改,在某些情况下(动态),相同的前缀()会更改为String。 Json格式的responseMessage对象: { "applicationType":"1", "responseMessage":{ "surname":"Jhon", "forename":" taylor", "dob":"17081990", "refNo":"3394909238490F", "result":"Received" } } responseMessage Json格式会动态更改为字符串类型: { "applicationType":"4", "responseMessage":"Success" } 我的问题是,因为改造具有内置的JSON解析功能,所以我必须为每个请求分配单个POJO!但不幸的是,REST-API是基于动态JSON响应构建的。前缀将在成功(...)和失败(...)方法中从字符串随机更改为对象! void doTrackRef(Map<String, String> paramsref2) { RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("http://192.168.100.44/RestDemo").build(); TrackerRefRequest userref = restAdapter.create(TrackerRefRequest.class); userref.login(paramsref2, new Callback<TrackerRefResponse>() { @Override public void success( TrackerRefResponse trackdetailresponse, Response response) { Toast.makeText(TrackerActivity.this, …
82 android  json  gson  retrofit 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.