1 Replies - 564 Views - Last Post: 21 November 2011 - 12:54 PM

#1 thebakhu  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 25
  • Joined: 29-August 10

Score Card: add 20 edittext box values num and display in one textbox

Posted 21 November 2011 - 06:14 AM

I have already figured out the xml,
If you could help me in terms java what listeners can i use to call and how can i display the added value
note i cannot use any button. The sum has to added as you go on inputting by it self.
package com.dgms.android;

import android.accounts.Account;
import android.accounts.OnAccountsUpdateListener;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.onclickListener;
import android.widget.EditText;
import android.widget.TextView;

public class SubmitCourse extends Activity {
	
	private EditText p1r1, p1r2, sum1;
	
	//private int[] p1Scores = new int[18];
	//private int[] p2Scores = new int[18];
	//private int[] p3Scores = new int[18];
	//private int[] p4Scores = new int[18];
	//private int[] p5Scores = new int[18];
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.submitcourse);
		
		p1r1 = (EditText) findViewById(R.id.p1e1);
		p1r2 =  (EditText) findViewById(R.id.p1e2);
		sum1 =  (EditText) findViewById(R.id.p1esum);
	// listners to call the text box 
	//
		//and sum1 has to add p1r1 and p1r2 and display on p1esum;
		TextView t=new TextView(this); 
		t.setText(p1r1.getText()); 
		setContentView(t); 
		
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Score Card: add 20 edittext box values num and display in one textbox

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 278
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: Score Card: add 20 edittext box values num and display in one textbox

Posted 21 November 2011 - 12:54 PM

I would suggest adding aTextWatcher to your EditText.
Ex:
p1r1.addTextChangedListener(new TextWatcher(){
        public void afterTextChanged(Editable s) {
            // code goes here
        }
        public void beforeTextChanged(CharSequence s, int start, int count, int after){}
        public void onTextChanged(CharSequence s, int start, int before, int count){}
    }); 


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1