Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old November 23rd, 2011, 04:40 AM   #1 (permalink)
New Member
 
mineko's Avatar
 
Join Date: Nov 2011
Location: philippines
Posts: 7
 
Device(s): android 3.2
Thanks: 1
Thanked 0 Times in 0 Posts
Default HELP! Java App: Add onclicklistener to TextView and Timer

Good day! XD

I'm Computer Engineering student having my internship and my boss assigned me to make an android application for Basketball Scoreboard which I'm having a hard time for I don't have lot of Java courses.

As of now,I'm confused on how to change the value of the TextView by onclicklistener. And a timer which upon clicking the textview of timer, it will start to count down from e.g. 10 minutes and to pause the timer, clicking the timer's textview again.

My java code looks like this:

package com;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
//import android.widget.TextView;
//import android.widget.TextView;
import app.scoreboard.R;
//import app.scoreboard.R.id;

public class scoreboardActivity extends Activity {
/** Called when the activity is first created. */
//private TextView HScore;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);

//HScore = (TextView)this.findViewById(id.hscore); //Home Score
//this.addView(HScore);
}
}



I'm using Android 3.2 (emulated). Any help would be greatly appreciated XD
T.T help help help

mineko is offline  
Reply With Quote
Sponsors
Old November 23rd, 2011, 04:52 AM   #2 (permalink)
Senior Member
 
Harry2's Avatar
 
Join Date: Jun 2010
Location: Black Forest
Posts: 2,856
 
Device(s): One X, Sensation, DHD, Desire
Thanks: 172
Thanked 600 Times in 525 Posts
Default

I can't help you with Java but I've heard apps development with Basic is very easy and for beginners much faster than with Java

http://www.basic4ppc.com/index2.html

Harry
__________________
Google Translator is to blame for my English
Harry2 is online now  
Reply With Quote
Old November 24th, 2011, 08:27 PM   #3 (permalink)
New Member
 
mineko's Avatar
 
Join Date: Nov 2011
Location: philippines
Posts: 7
 
Device(s): android 3.2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I have made a development regarding my program but it seems It really giving me hard time XD How do you increase the value of TextView where its value is e.g. is 0? And Please help me with the timer.. CountDown Timer with 10 minutes in initialization.

this is the code i have made so far:


public void onCreate(Bundle cute) {
super.onCreate(cute);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);

// If(updateTime()== TRUE)
updateTime();

handler.removeCallbacks(updateTimeTask);
handler.postDelayed(updateTimeTask, 1000);

Button exit =(Button) findViewById(R.id.exit);
exit.setOnClickListener(mExitListener);

Button reset =(Button) findViewById(R.id.reset);
reset.setOnClickListener(mResetListener);

HScore = (TextView)this.findViewById(R.id.hscore); //Home Score
HScore.setOnClickListener(mHscoreListener);

VScore = (TextView)this.findViewById(R.id.vscore); //Visitor Score

VScore.setOnClickListener(vscoreClickListener);

PScore = (TextView)this.findViewById(R.id.pscore); //Period Score
PScore.setOnClickListener(pscoreClickListener);

Foul1 = (TextView)this.findViewById(R.id.hfoul); // HFoul + 1
Foul1.setOnClickListener(foul1ClickListener);

Foul2 = (TextView)this.findViewById(R.id.vfoul); // VFoul + 1
Foul2.setOnClickListener(foul2ClickListener);


}//end of cuteness

private OnClickListener foul1ClickListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE
}; };

private OnClickListener foul2ClickListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE
}};
private OnClickListener mHscoreListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE
}; };

private OnClickListener vscoreClickListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE
}};
private OnClickListener pscoreClickListener = new OnClickListener() {
public void onClick(View v) {
//DO INCREASE after timer became 00:00
}};

private OnClickListener mResetListener = new OnClickListener() {
public void onClick(View v) {
onStop(); }; };

private OnClickListener mExitListener = new OnClickListener() {
public void onClick(View v) {
onDestroy(); }; };

protected void onReset() {
super.onDestroy();
//do stuff
}//onReset


private void updateTime() {
//long start = 0;
final TextView time = (TextView) findViewById(R.id.time);
//while(){

final Date currentTime1 = new Date( 15000);
final SimpleDateFormat formatterTime = new SimpleDateFormat( "mm:ss" );
time.setText( formatterTime.format(currentTime1) );

//start++;
//}//while
}

private Runnable updateTimeTask = new Runnable() {
public void run() {
updateTime();
handler.postDelayed(this, 1000);
}
};


@Override
protected void onDestroy() {
super.onDestroy();
System.exit(0);
}//onDestroy

@Override
protected void onResume() {
super.onResume();
handler.removeCallbacks(updateTimeTask);
handler.postDelayed(updateTimeTask, 1000);
}//onResume

@Override
protected void onPause() {
super.onPause();
//do stuff
}//onStop

@Override
protected void onStop() {
super.onStop();
handler.removeCallbacks(updateTimeTask);
}//onStop

}//end of the world



TY TY TY TY
mineko is offline  
Reply With Quote
Old November 25th, 2011, 06:28 PM   #4 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

moved to app dev section
alostpacket is offline  
Reply With Quote
Old December 5th, 2011, 03:09 PM   #5 (permalink)
New Member
 
Join Date: Dec 2011
Posts: 4
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

huh. very confusing code. are all the codes from Android library? so you only post methods right? I didn't see where most of the variables come from.
tkh08001 is offline  
Last edited by tkh08001; December 5th, 2011 at 03:12 PM.
Reply With Quote
Old December 7th, 2011, 10:37 PM   #6 (permalink)
New Member
 
mineko's Avatar
 
Join Date: Nov 2011
Location: philippines
Posts: 7
 
Device(s): android 3.2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I had it declared before the bundle. I have already got what I am asking so the question is closed . thanks for the reply by the way
mineko is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:49 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo