小编tax*_*eta的帖子

android.content.res.Resources $ NotFoundException异常:来自drawable资源ID的文件res/drawable/my.xml

这个xml有什么问题,我试图按下按钮的感觉.我得到一个例外,我无法理解.ResourceNotFound

在我的layout.xml中

<Button
    android:id="@+id/submit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/submitbuttonpress"
    android:text="Submit"
    android:textColor="#eeeee4"
    android:typeface="monospace" />
Run Code Online (Sandbox Code Playgroud)

我在drawable文件夹中的submitbuttonpress.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false" android:background="#AAAAAA" />
    <item android:state_pressed="true" android:background="#777777" />
</selector>
Run Code Online (Sandbox Code Playgroud)

异常(logcat)

07-17 19:07:25.072: E/AndroidRuntime(2225): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.taxeeta/com.itaxeeta.BookingExperience}: android.view.InflateException: Binary XML file line #326: Error inflating class android.widget.Button
07-17 19:07:25.072: E/AndroidRuntime(2225):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
07-17 19:07:25.072: E/AndroidRuntime(2225):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
07-17 19:07:25.072: E/AndroidRuntime(2225):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-17 19:07:25.072: E/AndroidRuntime(2225):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
07-17 19:07:25.072: E/AndroidRuntime(2225):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 19:07:25.072: E/AndroidRuntime(2225):     at android.os.Looper.loop(Looper.java:130)
07-17 19:07:25.072: E/AndroidRuntime(2225): …
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

IndexOutOfBoundsException:charAt:0> =某些Android版本的长度为0

我正在尝试使用Java和Eclipse来创建应用程序(目前正在使用B4A,但希望扩展我的可用资源,以及创建库的能力)

在尝试使用片段实现对话时,我已经按照此处的示例进行操作.

我一直在

05-06 13:40:21.060: E/SensorManager(18538): thread start
05-06 13:40:21.105: E/Dynamiclayout(18538): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
Run Code Online (Sandbox Code Playgroud)

我已经尝试过调试,但调试器永远不会停止任何错误(我是这个调试器的新手,所以不知道如何解决这个问题).

有谁看到引起异常的地方?(只是为了确保它不是任何地方的胖手指,我通过git下载,并尝试了它,并在logcat中收到完全相同的错误)

这是我的mainActivity.java:

package com.example.fragmenttest;
import com.example.fragmenttest.EditNameDialog.EditNameDialogListener;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends FragmentActivity  implements EditNameDialogListener {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_edit_name);
    showEditDialog();
}

private void showEditDialog() {
    FragmentManager fm = getSupportFragmentManager();
    EditNameDialog editNameDialog = new EditNameDialog();
    editNameDialog.show(fm, "fragment_edit_name");
}

@Override
public void onFinishEditDialog(String inputText) {
    Toast.makeText(this, "Hi, …
Run Code Online (Sandbox Code Playgroud)

java android indexoutofboundsexception

10
推荐指数
1
解决办法
3965
查看次数

使用单独的线程时,我得到`android.os.NetworkOnMainThreadException`

在我的Activity中我使用了一个处理程序

Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg)  {   
               //do GUI stuff, edit views, etc..
    }
};
Run Code Online (Sandbox Code Playgroud)

我也有一个Runnable,发布到PHP并等待json响应

Runnable runnable3 = new Runnable() {
        public void run() { 
            JSONParserArray jsonParserRun = new JSONParserArray();
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("p1", "myParam1"));
            try {
                String link = "http://mylink.com/someFileOnServer.php";
                JSONArray jArray = jsonParserRun.makeHttpRequest(link , "POST",
                        params);
                if (jArray != null && jArray.length() != 0) {
                } else {
                    //either null (because of throwing exception) or empty …
Run Code Online (Sandbox Code Playgroud)

android ui-thread android-handler

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

JSON在响应时返回空值

response给了我null价值观,但当我运行同样的东西时fiddler,我得到了很多数据.我编写的代码非常少,并使用在线工具生成代码.我想知道我搞砸了.

    Publications response = null ;
    // First open URL connection (using JDK; similar with other libs)
    try {
        URL url = new URL(
                "http://myserver:myport/Mobile/GetPublications");
        HttpURLConnection connection = (HttpURLConnection)url.openConnection() ;
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setRequestMethod("POST") ;
        connection.setRequestProperty("Content-Type", "application/json") ;
        // and other configuration if you want, timeouts etc
        // then send JSON request
        Publications request = new Publications(); // POJO with getters or public fields
        ObjectMapper mapper = new ObjectMapper(); 
        mapper.writeValue(connection.getOutputStream(), request);
        // and read response …
Run Code Online (Sandbox Code Playgroud)

java json web-services jackson

0
推荐指数
1
解决办法
7063
查看次数