I want to make a function which debug when image's name equal "aaa". So I think that I should get image's name.
for example, there is a ImageView
.
ImageView img1 = (ImageView) findViewById(R.drawable.button);
public void passMSg(){
if(name == "button"){ // "name" means image's name. = button
Toast. ~
}
I find other questions. But I can't understand and I think that is not answer which I want. Who can help me?
if your image is a file like 'aaa.jpg/png..'
try to use the APIs of String such as subString().indexOf()
and your code may be like this:
int index = name.indexOf(".");
String name = name.subString(name,0,index);