hello, I am new in android developing and need your help.I have 3 tabs and
I want every time the user clicks on the next button on tab quiz a string
to be shown in a textview in tab results.How am I supposed to do this??
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
package com.example.ergasia1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class QuizActivity extends Activity implements OnCheckedChangeListener{
int counter=0;
RadioGroup rg;
RadioButton er1,er2,er3,er4;
TextView tvDisplay,apanthseis;
ImageButton img;
Create[] p=new Create[5];
String apanthsh="";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.quiz);
rg=(RadioGroup)findViewById(R.id.RadioGroup1);
er1=(RadioButton)findViewById(R.id.rErwt1);
er2=(RadioButton)findViewById(R.id.rErwt2);
er3=(RadioButton)findViewById(R.id.rErwt3);
er4=(RadioButton)findViewById(R.id.rErwt4);
tvDisplay=(TextView)findViewById(R.id.tvDisplay1);
img=(ImageButton)findViewById(R.id.imbutt1);
apanthseis=(TextView)findViewById(R.id.apanthseis);
p[0]=new Create("????? ??? ???? ???????? ???????? ?????????????? ?????? ?? ???? ??? ?????????;","? ?????????? ???????","? ?????? ?????????","? ?????? ????????","? ??????? ?????","? ??????? ?????");
p[1]=new Create("????? ??? ???? ???????? ??????????????, ??? ?????????? ???? ???????? ??? ??????? ??? ??? Euro 2004, ?????? ?? ????????? ??? ????; ","? ??????? ?????????? ??? ???????????","? ??????? ?????","? ?????? ???????","? ????? ?????????","? ??????? ?????????? ??? ???????????");
p[2]=new Create("???? ??? ???? ???????? ???????????? (??? ??????????? ???? ?? ??????) ?????? ??? ???????? ?? ?????? ??? ?????????? ??? ??? ????! ?????; ","????????? ??? ??????","???????? ????? ??? ????????","????????? ????????","?????? ?????????","????????? ??? ??????");
p[3]=new Create("???? ?? ???????? ????????? ??????? ??????? ??????? ??? ???? ????????? ??? ???? ????. ????? ??? ????! ?????;","???????? ?????","???????? ???????????","??????? ??????","????? ???????","????? ???????");
p[4]=new Create("????? ??? ???? ???????? ?????????? ?????????????? ??? ??????????? ???? ?? ?????? ?????? ??? ???? ????????? ??? ???? ????;","? ???????? ???? ???????","? ???????????? ???? ?????","? ?????????? ??????? ??????","? ?????????????? ???? ???","? ???????? ???? ???????");
Emfanish();
rg.setOnCheckedChangeListener(this);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(counter<p.length){
Emfanish();
apanthsh+="??????? "+(counter+1)+" :";
//apanthseis.setText(apanthsh);
//counter++;
}
else{
img.setClickable(false);
}
}
});
}
public void onCheckedChanged(RadioGroup arg0, int arg1) {
switch(arg1)
{
case R.id.rErwt1:
if(((String)er1.getText()).equals(p[counter].getSwsthAp())){
apanthsh+=" ?????? ??? ????? ????????";
}
else{
apanthsh+=" ? ????? ???????? ???? ??????? :"+p[counter].getErwthsh();
apanthsh+=" ????? :"+p[counter].getSwsthAp();
}
break;
case R.id.rErwt2:
if(((String)er2.getText()).equals(p[counter].getSwsthAp())){
apanthsh+=" ?????? ??? ????? ????????";
}
else{
apanthsh+=" ? ????? ???????? ???? ??????? :"+p[counter].getErwthsh();
apanthsh+=" ????? :"+p[counter].getSwsthAp();
}
break;
case R.id.rErwt3:
if(((String)er3.getText()).equals(p[counter].getSwsthAp())){
apanthsh+=" ?????? ??? ????? ????????";
}
else{
apanthsh+=" ? ????? ???????? ???? ??????? :"+p[counter].getErwthsh();
apanthsh+=" ????? :"+p[counter].getSwsthAp();
}
break;
case R.id.rErwt4:
if(((String)er4.getText()).equals(p[counter].getSwsthAp())){
apanthsh+=" ?????? ??? ????? ????????";
}
else{
apanthsh+=" ? ????? ???????? ???? ??????? :"+p[counter].getErwthsh();
apanthsh+=" ????? :"+p[counter].getSwsthAp();
}
break;
}
}
public void Emfanish(){
tvDisplay.setText(p[counter].getErwthsh());
er1.setText(p[counter].getAp1());
er2.setText(p[counter].getAp2());
er3.setText(p[counter].getAp3());
er4.setText(p[counter].getAp4());
counter++;
}
}
package com.example.ergasia1;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class ResultActivity extends Activity{
TextView apanthseis;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.results);
apanthseis=(TextView)findViewById(R.id.apanthseis);
}
}
package com.example.ergasia1;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = getTabHost();
TabSpec odhgiesspec = tabHost.newTabSpec("ODHGIES");
odhgiesspec.setIndicator("ODHGIES", getResources().getDrawable(R.drawable.icon_odhgies_tab));
Intent odhgiesIntent = new Intent(this, OdhgiesActivity.class);
odhgiesspec.setContent(odhgiesIntent);
TabSpec quizspec = tabHost.newTabSpec("QUIZ");
quizspec.setIndicator("QUIZ", getResources().getDrawable(R.drawable.icon_quiz_tab));
Intent quizIntent = new Intent(this, QuizActivity.class);
quizspec.setContent(quizIntent);
TabSpec resultspec = tabHost.newTabSpec("RESULTS");
resultspec.setIndicator("RESULTS", getResources().getDrawable(R.drawable.icon_result_tab));
Intent resultIntent = new Intent(this, ResultActivity.class);
resultspec.setContent(resultIntent);
tabHost.addTab(odhgiesspec);
tabHost.addTab(quizspec);
tabHost.addTab(resultspec);
}
}
package com.example.ergasia1;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class OdhgiesActivity extends Activity{
TextView tvs;
String odhgies="";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.odhgies);
tvs=(TextView)findViewById(R.id.tV1);
tvs.setText(odhgies);
}
}
package com.example.ergasia1;
public class Create {
private String erwthsh;
private String ap1;
private String ap2;
private String swsthAp;
public void setErwthsh(String erwthsh) {
this.erwthsh = erwthsh;
}
public void setAp1(String ap1) {
this.ap1 = ap1;
}
public void setAp2(String ap2) {
this.ap2 = ap2;
}
public void setAp3(String ap3) {
this.ap3 = ap3;
}
public void setAp4(String ap4) {
this.ap4 = ap4;
}
private String ap3;
private String ap4;
public Create(String erwthsh,String ap1,String ap2,String ap3,String ap4,String swsthAp){
this.erwthsh=erwthsh;
this.ap1=ap1;
this.ap2=ap2;
this.ap3=ap3;
this.ap4=ap4;
this.swsthAp=swsthAp;
}
public String getErwthsh(){
return erwthsh;
}
public String getAp1(){
return ap1;
}
public String getAp2(){
return ap2;
}
public String getAp3(){
return ap3;
}
public String getAp4(){
return ap4;
}
public String getSwsthAp() {
return swsthAp;
}
public void setSwsthAp(String swsthAp) {
this.swsthAp = swsthAp;
}
}