0

I'm trying to learn a little about android programming on the side, but I am still a beginner, so any help would be really appreciated, I'm sure this isn't too hard for someone with some experience.

What I want to do is be able to load up an activity, which originally just an "add button" button.

When the add button is clicked the page links to 3 user inputted strings (say str1, str2, str3). I want to be able to click a button on this second activity and have the screen link back to the original activity, with a new button added displaying "str1 str2 str3" and the "add button" button underneath that new one.

I have managed to do the first part and have created all of the fields and the button on the 2nd activity, but I don't know how to go about creating the button back on the first activity dynamically and with the string desired.

Thank you all in advance!!

seanscal
  • 568
  • 2
  • 9
  • 33
  • Check this out http://stackoverflow.com/questions/1851633/how-to-add-button-dynamically-in-android – puj Mar 16 '15 at 22:02
  • @puj I have the button dynamically adding to the current page, but I cant get it to add a new button above the add button on the main screen once the second screen is submitted – seanscal Mar 17 '15 at 04:14

1 Answers1

0

in your layout add a button

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="..."/>

and in your java try this:

Button mButton = (Button)findViewById(R.id.button);
mButton.setTextSize(str1+str2+str3);

and for button click event:

    mButton.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View view) {

       //do what you want here

     }
   });
Milad Nouri
  • 1,587
  • 1
  • 21
  • 32
  • I have the button dynamically adding to the current page, but I cant get it to add a new button above the add button on the main screen once the second screen is submitted – seanscal Mar 17 '15 at 04:15