Skip to main content

Working With Android Studio

Working With Android Studio  

 [# 1]



Video Link:       https://youtu.be/9zcki3STZ00    



Please Watch The Above Video If You haven't Watched It Already



1)  Open Android Studio and create a new project .

2) Give a name for your application and also set the package name.



3) Set The API level





4) Choose an Activity




5) Set the Activity Name and Layout Name





6) Click On Finish. Your project will be ready in few minutes.


7) Navigate to the layout directory and open activity_main.xml file


8)The code used in the video is given here

<?xml version="1.0" encoding="utf-8"?><LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     tools:context=".MainActivity">


<Button     android:id="@+id/btn1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="Display My name"     android:textAllCaps="false"/>


<TextView     android:id="@+id/txt1"     android:textStyle="bold"     android:textSize="24sp"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="Hello World!" />

</LinearLayout>




Screenshot 




9) Next Naviagte to MainActivity.java file. The code used is given below

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


public class MainActivity extends AppCompatActivity {


private Button btn;
private TextView txt;


    @Override 

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


       btn=(Button)findViewById(R.id.btn1);
       txt=(TextView)findViewById(R.id.txt1);



    btn.setOnClickListener(new View.OnClickListener() {
        @Override 
          public void onClick(View v) {
          Toast.makeText(MainActivity.this,"You clicked this button            now",Toast.LENGTH_LONG).show();
          txt.setText("Sketch Logic");

      }

    });

   }


  }




screenshot





10) Now Run Your App Test the app on your real device or emulator.
If you get any errors please comment below










Comments

Did you like this tutorial ?

Popular posts from this blog

Add Edittext Inside Dialog Box

Add Edittext Inside Dialog Box If you haven`t yet watched the video... Watch  it right  now!!! The code used in the above video is available here. final EditText edittext1= new EditText(MainActivity.this); LinearLayout.LayoutParams lpar = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); edittext1.setLayoutParams(lpar); dialog.setView(edittext1); textview1.setText(edittext1.getText());

Create Custom Popup Window using Sketchware

Create Custom Popup Window using Sketchware Refer the video below if  you get stuck.  1) Add a custom view named window.You can name it according to your wish.  2)Design your popup window.  2) Now, In the logic section,In OnCLick event of button.Add the following  code Create a view View popupView = getLayoutInflater().inflate(R.layout.window, null); Popup window  final PopupWindow popup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); Initialize  Button b1 = popupView.findViewById(R.id.button1); Button b2 = popupView.findViewById(R.id.button2); OnClickListeners b1.setOnClickListener(new OnClickListener() { public void onClick(View view) { //below code will dismiss the popup window popup.dismiss(); } }); b2.setOnClickListener(new OnClickListener() { public void onClick(View view) { popup.dismiss(); } }); Show the...

Enable Downloads In Your Web Browser

Enable Downloads In Your WebBrowser Latest Tutorial..! 1) Create a new Web Browser   project in Sketchware      Below are some tutorials regarding this topic.      Please watch these tutorials . These tutorials will help you in understanding the topic. Part 1 Part 2 Part 3 3) Export the project which you have created in Sketchware to AIDE or Android Studio 4) Navigate to AndroidManifest.xml and add the following permission <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 5) Now Open MainActivity.java or the Java File where you want to add the Download Listener      and add the following code         webview1.setDownloadListener(new DownloadListener() {                       @Override          ...