Created
January 19, 2018 07:57
-
-
Save akshayrajkumar/26fe0c614b2aff09b3f9fdf2f75681ec to your computer and use it in GitHub Desktop.
Udacity android development PractiecSet2 Lesson 3 , Experimenting with code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.android.practiceset2; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.TextView; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// PASTE CODE YOU WANT TO TEST HERE | |
int raspberryPrice = 5; | |
display1("1 box: $" + raspberryPrice); | |
display2("2 boxes: $" + (raspberryPrice*2)); | |
display3("3 boxes: $" + (raspberryPrice * 3)); | |
} | |
/** | |
* Display methods that allow the text to appear on the screen. Don't worry if you don't know | |
* how these work yet. We'll be covering them in lesson 3. | |
*/ | |
public void display(String text) { | |
TextView t = (TextView) findViewById(R.id.display_text_view); | |
t.setText(text); | |
} | |
// public void display(int text) { | |
// TextView t = (TextView) findViewById(R.id.display_text_view); | |
// t.setText(text + ""); | |
// } | |
public void display1(String text) { | |
display(text); | |
} | |
public void display2(String text) { | |
TextView t = (TextView) findViewById(R.id.display_text_view_2); | |
t.setText(text); | |
} | |
public void display3(String text) { | |
TextView t = (TextView) findViewById(R.id.display_text_view_3); | |
t.setText(text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment