0

I know there's a lot of Answers in Google Search but it doesn't exactly fit from what I need.

I'm trying to get rid of "VIP" String part while using setText.

TextView removeTextPart = (TextView)v.findViewById(R.id.spinner_item_txt); String vip = "VIP";
        if (config.contains("VIP")) { //config is a external file in my assets folder which contains a filename "VIP - SOMETHING" 
            String vip = vip.replaceAll("VIP", "");
            removeTextPart.setText(vip+config);
        } 

I'm expecting that when it reads the VIP String Part in my assets file it will remove the String just like "VIP - Something" String will be Replaced/removed from this " - Something".

Sorry for my Bad English.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

0

I don't know what is your replaceAll function does but I think you should change

String vip = replaceAll("VIP", "");

to

String vip = string.replace("VIP", "");
Hakan Saglam
  • 211
  • 2
  • 7
0

Simple solution to replace some part of string from original string is :

removeTextPart.setText(originalString.replace("VIP", " "));

replace method will return a string, so you can directly print it or also save in another temporary string.

Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92