Click here to Skip to main content
14,638,532 members
Home » Discussions » Android
   

Android

 
AnswerRe: Current Android Studio // Is it 2017 ? Pin
Ganza Charles20-Jun-18 22:42
MemberGanza Charles20-Jun-18 22:42 
GeneralRe: Current Android Studio // Is it 2017 ? Pin
C-P-User-311-Nov-18 20:46
MemberC-P-User-311-Nov-18 20:46 
Question(ANDROID) -->How can data be send from the run method of a thread in a service to a client using Handler and Messeger? Pin
Member 119110659-Jun-18 22:36
MemberMember 119110659-Jun-18 22:36 
AnswerRe: (ANDROID) -->How can data be send from the run method of a thread in a service to a client using Handler and Messeger? Pin
Richard MacCutchan10-Jun-18 4:18
mveRichard MacCutchan10-Jun-18 4:18 
GeneralRe: (ANDROID) -->How can data be send from the run method of a thread in a service to a client using Handler and Messeger? Pin
Member 1191106510-Jun-18 9:24
MemberMember 1191106510-Jun-18 9:24 
GeneralRe: (ANDROID) -->How can data be send from the run method of a thread in a service to a client using Handler and Messeger? Pin
Richard MacCutchan10-Jun-18 22:06
mveRichard MacCutchan10-Jun-18 22:06 
SuggestionRe: (ANDROID) -->How can data be send from the run method of a thread in a service to a client using Handler and Messeger? Pin
David Crow11-Jun-18 2:16
MemberDavid Crow11-Jun-18 2:16 
QuestionAddition,Sub,Mul & divide issue Pin
Member 1126111131-May-18 2:22
MemberMember 1126111131-May-18 2:22 
Sir I have problem. Let suppose that I have data like 23,56,89,88,90,1234,3445. now I want to add them all and want to get result. but this code is giving me result like that 23+56+36=92 not 115. mean it make addition of just to previous values


Here is my code

**************
package com.example.maher.androidspinnertutorial;



import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;



public class calculatr extends AppCompatActivity {



    Button btn_1,btn_2,btn_3,btn_4,btn_5,btn_6,btn_7,btn_8,btn_9,btn_0,btn_Add,btn_Sub,btn_Mul,btn_Div,btn_calc,btn_dec,btn_clear;

    EditText ed1;



     float Value1, Value2;

    boolean mAddition, mSubtract, mMultiplication, mDivision ;



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_calculatr);



        btn_0 = (Button) findViewById(R.id.btn_0);

        btn_1 = (Button) findViewById(R.id.btn_1);

        btn_2 = (Button) findViewById(R.id.btn_2);

        btn_3 = (Button) findViewById(R.id.btn_3);

        btn_4 = (Button) findViewById(R.id.btn_4);

        btn_5 = (Button) findViewById(R.id.btn_5);

        btn_6 = (Button) findViewById(R.id.btn_6);

        btn_7 = (Button) findViewById(R.id.btn_7);

        btn_8 = (Button) findViewById(R.id.btn_8);

        btn_9 = (Button) findViewById(R.id.btn_9);

        btn_Add = (Button) findViewById(R.id.btn_Add);

        btn_Div = (Button) findViewById(R.id.btn_Div);

        btn_Sub = (Button) findViewById(R.id.btn_Sub);

        btn_Mul = (Button) findViewById(R.id.btn_Mul);

        btn_calc = (Button) findViewById(R.id.btn_calc);

        btn_dec = (Button) findViewById(R.id.btn_dec);

        btn_clear = (Button) findViewById(R.id.btn_clear);

        ed1 = (EditText) findViewById(R.id.edText1);



        btn_0.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"0");

            }

        });



        btn_1.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"1");

            }

        });



        btn_2.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"2");

            }

        });



        btn_3.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"3");

            }

        });



        btn_4.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"4");

            }

        });



        btn_5.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"5");

            }

        });



        btn_6.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"6");

            }

        });



        btn_7.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"7");

            }

        });



        btn_8.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"8");

            }

        });



        btn_9.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+"9");

            }

        });



        btn_dec.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText(ed1.getText()+".");

            }

        });



        btn_Add.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Value1 = Float.parseFloat(ed1.getText() + "");

                mAddition = true ;

                ed1.setText(null);


            }

        });



        btn_Sub.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Value1 = Float.parseFloat(ed1.getText() + "");

                mSubtract = true ;

                ed1.setText(null);

            }

        });



        btn_Mul.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Value1 = Float.parseFloat(ed1.getText() + "");

                mMultiplication = true ;

                ed1.setText(null);

            }

        });



        btn_Div.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Value1 = Float.parseFloat(ed1.getText()+"");

                mDivision = true ;

                ed1.setText(null);

            }

        });



        btn_calc.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Value2 = Float.parseFloat(ed1.getText() + "");



                if (mAddition == true){



                    ed1.setText(Value1 + Value2 +"");

                    mAddition=false;

                }





                if (mSubtract == true){

                    ed1.setText(Value1 - Value2 +"");

                    mSubtract=false;

                }



                if (mMultiplication == true){

                    ed1.setText(Value1 * Value2 + "");

                    mMultiplication=false;

                }



                if (mDivision == true){

                    ed1.setText(Value1 / Value2+"");

                    mDivision=false;

                }

            }

        });



        btn_clear.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                ed1.setText("");

            }

        });

    }



}



****************
could anyone help me please?/
AnswerRe: Addition,Sub,Mul & divide issue Pin
Richard MacCutchan2-Jun-18 2:44
mveRichard MacCutchan2-Jun-18 2:44 
QuestionXamarin WebView please help. Pin
Member 1335044424-May-18 6:03
MemberMember 1335044424-May-18 6:03 
AnswerRe: Xamarin WebView please help. Pin
David Crow24-May-18 9:34
MemberDavid Crow24-May-18 9:34 
GeneralRe: Xamarin WebView please help. Pin
Member 1335044425-May-18 11:07
MemberMember 1335044425-May-18 11:07 
QuestionRe: Xamarin WebView please help. Pin
David Crow28-May-18 15:59
MemberDavid Crow28-May-18 15:59 
QuestionAndroid code obfuscating Pin
AndroidVH21-May-18 23:14
MemberAndroidVH21-May-18 23:14 
SuggestionRe: Android code obfuscating Pin
Jochen Arndt21-May-18 23:54
professionalJochen Arndt21-May-18 23:54 
GeneralRe: Android code obfuscating Pin
AndroidVH22-May-18 2:23
MemberAndroidVH22-May-18 2:23 
GeneralRe: Android code obfuscating Pin
Jochen Arndt22-May-18 2:53
professionalJochen Arndt22-May-18 2:53 
GeneralRe: Android code obfuscating Pin
AndroidVH22-May-18 18:18
MemberAndroidVH22-May-18 18:18 
AnswerRe: Android code obfuscating Pin
David Crow22-May-18 2:28
MemberDavid Crow22-May-18 2:28 
Questionhow to append new elements in to an array list in android? Pin
rathilesh c20-May-18 0:10
Memberrathilesh c20-May-18 0:10 
QuestionRe: how to append new elements in to an array list in android? Pin
Richard MacCutchan20-May-18 1:23
mveRichard MacCutchan20-May-18 1:23 
AnswerRe: how to append new elements in to an array list in android? Pin
rathilesh c20-May-18 2:04
Memberrathilesh c20-May-18 2:04 
GeneralRe: how to append new elements in to an array list in android? Pin
Richard MacCutchan20-May-18 2:12
mveRichard MacCutchan20-May-18 2:12 
GeneralMessage Closed Pin
11-Jun-18 12:28
MemberLucifer rick11-Jun-18 12:28 
GeneralMessage Closed Pin
11-Jun-18 12:31
MemberLucifer rick11-Jun-18 12:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.