Reverse String Android App (Reversed)

This is my first app made which reverse any input a user give.

Software Required:
1. Android Studio
2.Adobe Xd


Designing:
It is done in adobe Xd




Coding:

XML part:
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout 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:background="@drawable/screen"    tools:context=".MainActivity">
    <EditText        android:id="@+id/reverse"        android:layout_width="334dp"        android:layout_height="57dp"        android:layout_marginStart="8dp"        android:layout_marginTop="8dp"        android:layout_marginEnd="8dp"        android:layout_marginBottom="8dp"        android:background="@drawable/input"        android:hint="@string/element"        android:textAlignment="center"        android:textSize="40sp"        android:inputType="text"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintHorizontal_bias="0.491"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent"        app:layout_constraintVertical_bias="0.471" />
    <Button        android:id="@+id/submit"        android:layout_width="185dp"        android:layout_height="68dp"        android:layout_marginStart="8dp"        android:layout_marginTop="8dp"        android:layout_marginEnd="8dp"        android:layout_marginBottom="8dp"        android:background="@drawable/submit"        android:text="@string/submit"        android:textAlignment="center"        android:textSize="23sp"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintHorizontal_bias="0.438"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent"        app:layout_constraintVertical_bias="0.672" /></android.support.constraint.ConstraintLayout>

Java part:
package tripathi.aditya.reversed;
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;
public class MainActivity extends AppCompatActivity {

    EditText reverse;    Button submit;    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);
        submit = (Button) findViewById(R.id.submit);        reverse = (EditText) findViewById(R.id.reverse);        BtnClick();    }

    private void BtnClick() {
        submit.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                StringBuffer buffer = new StringBuffer(reverse.getText().toString());                buffer.reverse();                reverse.setText(buffer.toString());            }
        });    }

}

Comments

Post a Comment

Feel free to leave a comment...

Popular posts from this blog

C++ programming toll plaza simulation program