0% found this document useful (0 votes)
17 views3 pages

Encoding: XML Resources String String String String String String Drawable Drawable Resources

The document contains code for an Android application. The String.xml file defines application resources like strings and a drawable. The MainActivity.java file contains code for an activity with two buttons and a text view to display a counter. When button 1 is clicked the counter increases by 1 and is displayed in the text view. When button 2 is clicked the counter decreases by 1 and is displayed in the text view.

Uploaded by

Siti Zulaikha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Encoding: XML Resources String String String String String String Drawable Drawable Resources

The document contains code for an Android application. The String.xml file defines application resources like strings and a drawable. The MainActivity.java file contains code for an activity with two buttons and a text view to display a counter. When button 1 is clicked the counter increases by 1 and is displayed in the text view. When button 2 is clicked the counter decreases by 1 and is displayed in the text view.

Uploaded by

Siti Zulaikha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

developer.android.com mybringback.

com
String.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Workshop.March</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> <drawable name="button">ic_launcher</drawable> </resources>

MainActivity.java

package com.ftsm.march;

import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.TextView;

public class FirstActivity extends Activity {

Button btn1, btn2; TextView tV; int counter;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first); btn1 = (Button)findViewById(R.id.button1); btn2 = (Button)findViewById(R.id.button2);

tV =

(TextView)findViewById(R.id.textView1);

counter = 0;

btn1.setOnClickListener(new View.OnClickListener() {

@Override public void onClick(View arg0) { // TODO Auto-generated method stub counter = counter++; tV.setText("Your Total is" + counter); } });

btn2.setOnClickListener(new View.OnClickListener() {

public void onClick(View arg0) { // 1000 Auto-generated method stub counter--;

tV.setText("Your Total is" + counter); } });

}}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy