0% found this document useful (0 votes)
26 views2 pages

Coding Help

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Coding Help

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.example.ayon.

hisuman;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

EditText t1;
TextView txt_result ;
Button btn ;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

t1 = (EditText)findViewById(R.id.editText);
txt_result =(TextView)findViewById(R.id.textView);
}

public void display(View v){


String s=t1.getText().toString();
txt_result.setText(s+"");
Toast.makeText(getBaseContext(),""+s,Toast.LENGTH_LONG).show();
}

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ayon.hisuman.MainActivity">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/myText"
android:layout_marginTop="48dp"
android:textAlignment="center"
android:textSize="@dimen/abc_text_size_large_material"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/textView" />

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="72dp"
android:hint="@string/myEditText" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/myButton"
android:id="@+id/button"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true"
android:onClick="display"
android:layout_marginTop="74dp" />
</RelativeLayout>

<resources>
<string name="app_name">Hello Suman</string>
<string name="myText">Hello App of Suman...</string>
<string name="myButton">Click Me</string>
<string name="myEditText">Enter any Text</string>
</resources>

How to create Android App under Android Studio 2.1.2:-


======================================================
File--New--New Project--Give name--Set Project Location--Next--Select Phone &
Tablet--Select Minimum SDK: API8: Android 2.2(Froyo)
--Next--Select Empty Activity--Next--Give Activity Name--Finish

Project Open with the Error:junit:junit:4.12


To solve this problem:Open Gradle Scripts then build.gradle(Module:app), Now
comment the line:
//testCompile 'junit:junit:4.12'
Now Build Menu--Rebuild Project.

Type the Coding Then, Tools Menu-->Android--AVD Manager--Select Virtual Device--


Nexus One API23--Under Actions Click on Launch Icon--
Android Emulator Opens--Wait few minutes to complete Loading--Run Menu--Run App--
Select Connected Device--Nexus One API 23--Get Result.

You might also like