簡體   English   中英

Eclipse中的“找不到源”錯誤

[英]“Source not found” error in Eclipse

開發我的第一個Android應用。 在模擬器上工作正常,但在電話上我收到"Source not found error" ViewRoot.handleMessage(Message)line:1757 按下應用程序上的4號按鈕並嘗試在手機上顯示媒體圖像時出現錯誤。

碼:

package com.example.famiily_connect_v1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class family_connect extends Activity implements OnClickListener {
    /** Called when the activity is first created. */

    Button incrementButton, decrementButton, makecallButton,
            media_cameraButton;
    TextView numberdisplayTextView;
    EditText inputEditText;
    int A = 0;

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

        incrementButton = (Button) findViewById(R.id.Button01);
        decrementButton = (Button) findViewById(R.id.Button02);
        makecallButton = (Button) findViewById(R.id.Button03);
        media_cameraButton = (Button) findViewById(R.id.Button04);
        numberdisplayTextView = (TextView) findViewById(R.id.TextView01);
        inputEditText = (EditText) findViewById(R.id.EditText01);

        incrementButton.setOnClickListener(this);
        decrementButton.setOnClickListener(this);
        makecallButton.setOnClickListener(this);
        media_cameraButton.setOnClickListener(this);
        numberdisplayTextView.setOnClickListener(this);
        inputEditText.setOnClickListener(this);

    }

    @Override
    public void onClick(View arg0) {
        switch (arg0.getId()) {
        case R.id.Button01:
            A++;
            numberdisplayTextView.setText(String.valueOf(A));
            break;
        case R.id.Button02:
            A--;
            numberdisplayTextView.setText(String.valueOf(A));
            break;
        case R.id.Button03:

            break;
        case R.id.Button04:
            Intent myIntent = new Intent();
            myIntent.setAction(Intent.ACTION_VIEW); 
         myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            startActivity(myIntent);
            break;
        default:
            break;
        }

    }
}

XML格式

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="#00AAAA">
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="@string/hello" />
    <LinearLayout android:id="@+id/LinearLayout01"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></LinearLayout>
    <Button android:id="@+id/Button01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="increment"></Button>
    <Button android:id="@+id/Button02" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="decrement"></Button>
    <Button android:id="@+id/Button03" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="make call"></Button>
    <Button android:id="@+id/Button04" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="media_camera"></Button>
    <TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:textSize="24sp"
        android:text="0" android:textStyle="bold" android:textColor="#000000"></TextView>
    <EditText android:id="@+id/EditText01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="enter new button text"></EditText>
    <RadioButton android:id="@+id/RadioButton01"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="camera"></RadioButton>
</LinearLayout>

在Eclipse中啟用LogCat

窗口>顯示視圖>其他> Android> LogCat

那么您可以找到什么是異常的真實描述。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM