[Solved] How to increment alphanumeric number in android? [closed]


You can’t increment alphanumeric values directly. if want to do so you need to write some lines of code for it

here is activity_main.xml

<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"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <TextView
        android:id="@+id/txt_autoincreament"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="click"
        android:onClick="Click"/>

</LinearLayout>

here is MainActivity.java

public class MainActivity extends AppCompatActivity {
    TextView autoTextIncreament;
    String stringValue="ABB";
    long intValue=20180001;

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

        autoTextIncreament = findViewById(R.id.txt_autoincreament);
    }

    public void Click(View view){
        autoTextIncreament.setText(getValue());
    }

    private String getValue() {
        return stringValue+String.valueOf(intValue++);
    }
}

hope this will help you.

2

solved How to increment alphanumeric number in android? [closed]