Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android studio get id name from view

//Don't get the ID name/string from the view ID.

//Instead use the 
android:tag = "String"
//in your xml 

//Then in Java use 
View.getTag()
  
//To still get the ID name/string from view ID.
getResources().getResourceEntryName(View.getId())
Comment

android get id of view

public void onClick(View v) {
    switch (v.getId()) {
    case R.id.add_04:
        Toast.makeText(MainActivity.this, "1", Toast.LENGTH_LONG).show();
        break;
    case R.id.add_05:
        Toast.makeText(MainActivity.this, "2", Toast.LENGTH_LONG).show();
        break;
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java rename file 
Java :: console java 
Java :: word count in a string using HashMap Collection 
Java :: java search arraylist 
Java :: Conversion from Java List to Array 
Java :: java iterator index 
Java :: quarkus maven skip test 
Java :: Java Create an OutputStream 
Java :: Area of a Circle in Java Programming 
Java :: java actionperformed 
Java :: java program to sort an array 
Java :: print statement in java 
Java :: convert arraylist to array int 
Java :: inbuild method to sum of an arraylist elements in java 
Java :: thread java timer 
Java :: how to strip spaces in java using split with other delimiters 
Java :: Caused by: java.io.EOFException: SSL peer shut down incorrectly 
Java :: rock paper scissors java 
Java :: add two variables in Java 
Java :: convert object array to int array java 
Java :: exception in thread "main" java.lang.unsupportedclassversionerror: has been compiled by a more recent version of the java runtime (class file version 55.0), this version of the java runtime only recognizes class file versions up to 52.0 
Java :: if checkbox checked java 
Java :: java get element occurrences in a list java 
Java :: java for item in array 
Java :: StackAsMyArrayList 
Java :: How to merge two sorted arrays into a single sorted bigger one? 
Java :: convert linkedlist to integer array java 
Java :: how to set java path in windows 10 
Java :: java get year difference between two dates 
Java :: display two dimensional array java 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =