小编Luf*_*ffy的帖子

java.lang.NumberFormatException:无效的int:""EXCEPTION

如果用户将edittext留空,则会发生错误java.lang.NumberFormatException:Invalid int:"".错误就行了

 if (a=="" && b=="")
Run Code Online (Sandbox Code Playgroud)

并且也在线

 int result = Integer.parseInt(a) + Integer.parseInt(b);
 t1.setText(Integer.toString(result));
Run Code Online (Sandbox Code Playgroud)

Calci.java

package com.example.calculator;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Calci extends Activity {
    TextView t1;
    EditText e1, e2;
    Button add, sub, mul, div;
    Context c=this;

    String b, a;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calci);
        e1 = (EditText) findViewById(R.id.EditText01);
        e2 = (EditText) findViewById(R.id.EditText02);
        add = (Button) findViewById(R.id.add);
        sub = …
Run Code Online (Sandbox Code Playgroud)

android exception

9
推荐指数
2
解决办法
4万
查看次数

Android - java.io.FileNotFoundException

当我将位图图像插入文件目录时,它显示文件未找到异常,它显示的是一个目录.

这是我的代码:

            File mFolder = new File(getFilesDir() + "/sample");

            if (!mFolder.exists()) {
                mFolder.mkdir();
            }
             FileOutputStream fos = null;
             try {
                 fos = new FileOutputStream(mFolder);
                 bitmap.compress(Bitmap.CompressFormat.PNG,70, fos);

                 fos.flush();
                 fos.close();
              //   MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
             }catch (FileNotFoundException e) {

                 e.printStackTrace();
             } catch (Exception e) {

                 e.printStackTrace();
             }
Run Code Online (Sandbox Code Playgroud)

logcat的:

07-12 01:08:05.434: W/System.err(8170): java.io.FileNotFoundException: /data/data/com.sample.sam/files/sample(Is a directory)
07-12 01:08:05.434: W/System.err(8170):     at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
07-12 01:08:05.434: W/System.err(8170):     at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:239)
07-12 01:08:05.444: W/System.err(8170):     at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
07-12 01:08:05.444: W/System.err(8170):     at java.io.FileOutputStream.<init>(FileOutputStream.java:77)
Run Code Online (Sandbox Code Playgroud)

android filenotfoundexception

9
推荐指数
1
解决办法
3万
查看次数

检索项目的父项时出错:找不到与给定名称"android:Theme.Material.Light"匹配的资源

我在styles.xml中收到此错误:

检索项目的父项时出错:找不到与给定名称"android:Theme.Material.Light"匹配的资源.

在清单中:

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="21" />
Run Code Online (Sandbox Code Playgroud)

Android Sdk经理:

我更新了所有的api 21和额外内容.

在此输入图像描述

在此输入图像描述

在订单和出口:

在此输入图像描述

值-V21/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="android:Theme.Material.Light">

        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:colorAccent">@color/accent</item>
        <item name="android:textColorPrimary">@color/text_primary</item>
        <item name="android:textColor">@color/text_secondary</item>
        <item name="android:navigationBarColor">@color/primary_dark</item>

    </style>
</resources>  
Run Code Online (Sandbox Code Playgroud)

安慰:

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:7: error: Error: No resource found that matches the given name: attr 'android:colorAccent'.

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:5: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.

E:\workspace\WelcomeToL\app\src\main\res\values-v21\styles.xml:6: error: …
Run Code Online (Sandbox Code Playgroud)

android android-styles android-5.0-lollipop

9
推荐指数
1
解决办法
2万
查看次数

将base64 imageString转换为位图以在ImageView中显示,在位图中显示null

(编辑)的

  • 在浏览器中访问API时,它正在下载图像.网址是http://example.com/api/v1/filedownloader.json?file=GvygDaYb64wUon0lxp2H1458543376.

  • 我更改了服务器名称并添加example.com到该URL.因此在浏览器中运行时不会下载图像文件.但是你可以在这里看到图像文件 .

  • 然后我用编码工具解码工具检查了文件.

  • 解码后,我得到了.bin file.然后我变成了.png format.只有这样我才能得到准确的图像.

  • 我不知道如何做所有这些功能来获取图像并在imageView中显示它.

  • 无论如何我用这个尝试了下面的代码:

logcat的:

03-24 04:29:43.816: E/OnResponse(15392): ÿØÿà??JFIF????????????ÿí??Photoshop 3.0??8BIM??????????g??9dXpsI_ORS9jWIcxWfWe(??bFBMD01000abe030000070e0000c51a0000161c0000251d0000bc2000007f350000fc370000323a00003f3c0000f4620000ÿâICC_PROFILE??????lcms????mntrRGB XYZ Ü????????)??9acspAPPL????????????????????????????????????????????????????öÖ??????????Ó-lcms??????????????????????????????????????????????????????????????????????????????????????????????
03-24 04:29:43.816: E/OnResponse(15392): desc??????ü??????^cprt????\??????wtpt????h??????bkpt????|??????rXYZ??????????gXYZ????¤??????bXYZ????¸??????rTRC????Ì??????@gTRC????Ì??????@bTRC????Ì??????@desc??????????????c2????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????text????????FB????XYZ ????????????öÖ??????????Ó-XYZ ????????????????3????¤XYZ ????????????o¢????8õ????XYZ ????????????b????·????ÚXYZ ????????????$ ????????¶Ïcurv????????????????????ËÉckö?Q4!ñ)2;FQw]íkpz±|¬i¿}ÓÃé0ÿÿÿÛ??C??       
03-24 04:29:43.816: E/OnResponse(15392):    

"##!  %*5-%'2(  .?/279<<<$-BFA:F5;<9ÿÛ??C
03-24 04:29:43.816: E/OnResponse(15392): 9& &99999999999999999999999999999999999999999999999999ÿÂ??¸¸??"??ÿÄ????????????????????????????ÿÄ??????????????????????????ÿÄ??????????????????????????ÿÚ??????????íÐÙG,!.Ph5ð8ò÷¸¥®ÐàÔ§DUdº
de??kP'.¤ÅS BG  ìóölâvw@+.ÆÖ®©$¸
Ø
03-24 04:29:43.816: E/OnResponse(15392): K¥Yp ³ºXC¹O/)u RÉuEÊ$£³UÂP©hL^ÅÌ ·üûÌ%§ EU-1i6Ss©,ÞÌõ®{·W¹k`¤I!kwt%ÙeP¦*Ôªóï-¿
03-24 04:29:43.816: E/OnResponse(15392):  l"4áá#^-KSIBá¯S¨jYeîÌùucÓq}Lvå^ jÍ [Bz¾·í'nUï#tE  ÂQ(äf)Uw(5ݨG/cUÙÀSAIÓ(´ÌÑY.,±iíÒ«Bଽ^pvf;TAX,KÄEµ XbìÜHqßìx¯Wf    ¬«R\¤.ªªì#IOYçx=ÿ??7+J%g(ªÉM*ÖhÙ­¶ìíZMøØ¹s^²Èó¡fº­(%F¬î\ÓF¥§*ÇÈÉ+«Çu{H륭]G4Q%A]Eñî>±3¦Y:,tÖØ&:×F3Óf]¡9ÖõQ9Zã??ÕZ3¼9zIÖy¶ÓT ÓPֺϫ@eÎv ìô}¿%ên[Tz)h6v¹n­,h°°?ÅfìÓOÇZ1ЮÑCdÖJí³íÁ±ÌN·VcÔpÐèkEÃ`W°+5hg
`Eçg4µãß4VzÆÏ[ã½-x7¨A`ºÊD5Wå®ky{º¬ZùöeÔÏG¶Br    VD&´³· …
Run Code Online (Sandbox Code Playgroud)

android android-volley

9
推荐指数
3
解决办法
3292
查看次数

无法加载memtrack模块-2

我在eclipse上为Android应用程序编写代码.但是我遇到了错误:

Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED.
Please check logcat output for more details.
Launch canceled!
Run Code Online (Sandbox Code Playgroud)

没有发布的答案(将事情改为小写/确保一切都关闭等等)修复了这个问题.

StackTrace错误:

Couldn't load memtrack module (No such file or directory) 
Failed to  load memtrack module: -2.
Run Code Online (Sandbox Code Playgroud)

有谁知道这意味着什么?

谢谢Z.

eclipse android logcat

8
推荐指数
1
解决办法
2万
查看次数

仅隐藏"滚动"操作栏选项卡上的"操作"栏

我在尝试在向下滚动时隐藏操作栏时出现问题.然后在向上滚动时,操作栏必须再次显示.

对于Eg:

我参考了这个教程.在这里你可以看到与隐藏相关的输出和相应代码并显示操作栏.

我正在展示我到目前为止得到的输出.

在此输入图像描述

向下滚动后:

在此输入图像描述

上面显示的屏幕截图,它也隐藏了操作栏标签.但它必须只隐藏操作栏.这是主要问题.

向上滚动后:

在此输入图像描述

上面的屏幕截图显示它显示带有标签的操作栏.

TopRatedFragment.java:

import info.androidhive.tabsswipe.R;
import android.app.ActionBar;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.widget.ScrollView;

public class TopRatedFragment extends Fragment implements ViewTreeObserver.OnScrollChangedListener {

    private float mActionBarHeight;
    private ActionBar actionBar;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_top_rated, container, false);

        final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
                new int[] { android.R.attr.actionBarSize });
        mActionBarHeight = styledAttributes.getDimension(0, 0);
        styledAttributes.recycle(); …
Run Code Online (Sandbox Code Playgroud)

android android-actionbar

7
推荐指数
1
解决办法
1万
查看次数

VM Aborting:致命信号6(SIGABRT)位于0x00001247(代码= -6)

我正在使用eclipse棒棒糖版.

我收到此错误:

虚拟机中止

致命信号6(SIGABRT)位于0x00001247(代码= -6)

下面我发布了完整的堆栈跟踪:

堆栈跟踪:

01-30 04:11:43.053: E/dalvikvm(4679): VM aborting

01-30 04:11:43.053: A/libc(4679): Fatal signal 6 (SIGABRT) at 0x00001247 (code=-6), thread 4679 (e.quranmadeeasy)

01-30 04:11:43.541: D/dalvikvm(4749): GC_FOR_ALLOC freed 124K, 6% free 3345K/3528K, paused 2ms, total 2ms
01-30 04:11:43.541: I/dalvikvm-heap(4749): Grow heap (frag case) to 4.395MB for 1127532-byte allocation
01-30 04:11:43.541: D/dalvikvm(4749): GC_FOR_ALLOC freed 0K, 4% free 4446K/4632K, paused 1ms, total 1ms
Run Code Online (Sandbox Code Playgroud)

Logcat没有指出错误行.所以我不知道如何解决这个错误.我试过这个答案.但它对我没有帮助.任何帮助都是最受欢迎的.谢谢.

android

6
推荐指数
1
解决办法
1万
查看次数

无法执行dex:多个dex文件定义Landroid/support/v7/util/ThreadUtil $ MainThreadCallback;

我无法执行dex:多个dex文件错误.

控制台错误:

[2015-12-22 16:39:38 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v7/util/ThreadUtil$MainThreadCallback;
[2015-12-22 16:39:38 - Talkr] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v7/util/ThreadUtil$MainThreadCallback;
Run Code Online (Sandbox Code Playgroud)

下面我发布了订单和导出的截图.我无法检查android私有库.如果我检查它,我的应用程序变慢,我无法运行该应用程序.

订单和出口:

在此输入图像描述

编辑:如果我取消选中我的所有库,将解决多个dex错误.但是我在Debug中获得Thread挂起异常.

下面我发布了调试错误.

在此输入图像描述

任何人都知道如何解决这个问题.谢谢.

android dex

6
推荐指数
1
解决办法
1161
查看次数

如何在android中直接分享http图片到twitter?

到目前为止我在stackoverflow帖子中搜索了,我可以直接将文本分享给twitter,而不显示分享的弹出对话框.这意味着当我点击按钮时,它会直接重定向到Twitter应用程序并显示文本.

我唯一的问题是我必须直接与Twitter分享http图像.

下面我发布了我到目前为止所尝试的代码:

UsersAdapter.java:

// Create intent using ACTION_VIEW and a normal Twitter url:
        String tweetUrl = String.format("https://twitter.com/intent/tweet?text=%s&url=%s",
                urlEncode(strShareText), 
                urlEncode(strShareImageUrl));
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tweetUrl));

        // Narrow down to official Twitter app, if available:
        List<ResolveInfo> matches = context.getPackageManager().queryIntentActivities(intent, 0);
        for (ResolveInfo info : matches) {
            if (info.activityInfo.packageName.toLowerCase().startsWith("com.twitter")) {
                intent.setPackage(info.activityInfo.packageName);
            }
        }

        context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,文本在twitter中正确显示.但是在http url中显示了图像.

任何人都知道如何直接分享图像到Twitter应用程序而不显示链接.

twitter android android-twitter

6
推荐指数
1
解决办法
1287
查看次数

如何在nativescript中为stacklayout提供border和border-radius

我是nativescript的新手.我不知道如何给stacklayout提供border和border-radius.

下面我发布了我到目前为止所尝试的内容:

component.html:

 <StackLayout class ="stackBorder" orientation="horizontal">
    <Label text="Label 1" width="50" height="50" > </Label>
    <Label text="Label 2" width="50" height="50" > </Label>
    <Label text="Label 3" width="50" height="50" backgroundColor="white"> </Label>
    <Label text="Label 4" width="50" height="50" backgroundColor="white"> </Label>
  </StackLayout>
Run Code Online (Sandbox Code Playgroud)

component.css:

StackLayout {
  margin: 10;
  background-color: green;

}

.stackBorder {
 border: 2px solid red;
   border-radius: 8px;
}
Run Code Online (Sandbox Code Playgroud)

component.ts:

@Component({
    selector: "sdk-child-component",
    moduleId: module.id,
    templateUrl: "./component.html",
    styleUrls: ["./component.css"]
})
Run Code Online (Sandbox Code Playgroud)

最后我无法在stacklayout中看到边框.

css typescript nativescript angular2-nativescript

6
推荐指数
2
解决办法
3486
查看次数