android中的java物理应用程序(数学)

时间:2014-03-21 11:51:45

标签: java android eclipse math

基本上,我是java的新手,我必须制作一个可以做简单物理方程式的android应用程序,比如I = Q * t ....等等,基本上我不能为我的生活得到输出的结果,有谁有任何想法,为什么这不会在模拟器上工作?

我已经尝试过将意图和所有种类放在那里。请帮忙

public class Current extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_current);
        // Show the Up button in the action bar.
        setupActionBar();

        @SuppressWarnings("unused")
        Intent intent = getIntent();
    }

        public void Main(String[]args){

        Button calc1 = (Button)findViewById(string.Calculate_Current);

        calc1.setOnClickListener(new View.OnClickListener() {


             public void onClick(View v) {

                // IIIIII HATE JAVA

                EditText Charge1 = (EditText)findViewById(R.id.number_input_2);    
                EditText Time1 = (EditText)findViewById(R.id.number_input_3);
                TextView Distances_answer = (TextView)findViewById(R.id.Distances_answer);




                double charge = Double.parseDouble(Charge1.getText().toString());
                double Time = Double.parseDouble(Time1.getText().toString());

                @SuppressWarnings("unused")
                Intent intent = new Intent();

                Distances_answer.setText("" + charge + Time);



            }
        });

1 个答案:

答案 0 :(得分:0)

我觉得你正在从两个edittexts中输入收费和时间,然后点击一个按钮,你正在更新一个textview,把那个收费和时间的产品放在那里。试试这个

public class Current extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_name);
    // Show the Up button in the action bar.
    setupActionBar();


  Button calc1 = (Button)findViewById(R.id.buttons_id_in_layout);

    calc1.setOnClickListener(new View.OnClickListener() {


         public void onClick(View v) {

            EditText Charge1 = (EditText)findViewById(R.id.number_input_2);    
            EditText Time1 = (EditText)findViewById(R.id.number_input_3);
            TextView Distances_answer = (TextView)findViewById(R.id.distances_answer);
            double charge = Double.parseDouble(Charge1.getText().toString());
            double time = Double.parseDouble(Time1.getText().toString());
//Time is a class in Java
            Distances_answer.setText("" +charge*time);

        }
    });
}