小编Luc*_*cia的帖子

运算符*未定义

I am trying to make a simple calculator that multiples. I have most of it done, but I keep getting the same error: The operator*is undefined for the argument types Double, EditText.

I searched the questions asked by others, but the only simple one dealt with something different than doubles. Does anyone know how to fix it?

package com.deitel.multiplicationtables;

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

//Implements the listener for an onclick event (implements View.onClickListener) …
Run Code Online (Sandbox Code Playgroud)

java android undefined operator-keyword

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

必须在自己的文件中定义公共类

我试图在一个应用程序中使用两个视图来提出用户的行星重量.在多次重写java之后,我终于让它工作了......主要是,但是在公共类Planets上它告诉我"公共类型行星必须在它自己的文件中定义." 我进入清单并为它做了一个活动,但这没有任何帮助.行星已经是我的一个xml文件的名称.如何将公共类型转换为自己的文件?

activity_main.xml中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/askwtTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="19dp"
    android:text="@string/askwt" />

<EditText
    android:id="@+id/inputwtEditText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/askwtTextView"
    android:layout_below="@+id/askwtTextView"
    android:layout_marginTop="26dp"
    android:ems="10"
    android:inputType="numberDecimal" />

<Button
    android:id="@+id/enterButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/inputwtEditText"
    android:layout_below="@+id/inputwtEditText"
    android:layout_marginTop="38dp"
    android:onClick="buttonclick"
    android:text="@string/enter" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Planets.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/planetTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/planet" />

<TextView
    android:id="@+id/textViewform2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="" />

<RadioGroup
    android:id="@+id/radioGroup1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RadioButton
        android:id="@+id/mercuryRadio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="@string/mercury" />

    <RadioButton
        android:id="@+id/venusRadio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/venus" /> …
Run Code Online (Sandbox Code Playgroud)

android class

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

多个答案,但我只想要一个

我创建了几个if else语句,同时解析了一个double,然后答案是double =每个else语句.当我运行该程序时,它运行得很漂亮,除了每个答案如果给出...

//Makes a variable for the entered amount
            double mercurypf;
            double venuspf;
            double earthpf;
            double marspf;
            double jupiterpf;
            double saturnpf;
            double uranuspf;
            double neptunepf;
            double plutopf;


            // constants
            final double mercuryforce = 0.38; 
            final double venusforce = 0.91; 
            final double earthforce = 1.00; 
            final double marsforce = 0.38; 
            final double jupiterforce = 2.34; 
            final double saturnforce = 1.06; 
            final double uranusforce = .92;
            final double neptuneforce = 1.19;
            final double plutoforce = 0.06;



            // Code used to determine …
Run Code Online (Sandbox Code Playgroud)

android

-1
推荐指数
1
解决办法
46
查看次数

标签 统计

android ×3

class ×1

java ×1

operator-keyword ×1

undefined ×1