Endy Sun
Endy Sun

Reputation: 23

Strings.xml does not recognise chinese characters

public void displayDecDeg(){

        DecimalFormat latlongF = new DecimalFormat("0.00000"); 
        latTV.setText(R.string.latitude + latlongF.format(lat));
        longTV.setText(R.string.longitude + latlongF.format(longi));

    }

In the localized version of the Strings.xml file, there is chinese text, but it shows up as numbers while testing.

However, when the chinese characters are hardcoded in place of R.string.longitude, it shows up fine.

<string name="latitude">纬度: </string>
<string name="longitude">经度:</string><string name="decDeg">十进制度</string>

Upvotes: 2

Views: 315

Answers (1)

zbz.lvlv
zbz.lvlv

Reputation: 3797

Ok just figured out the solution for my friend. Use getResources().getString(R.string.latitude) instead of R.string.latitude.

Upvotes: 1

Related Questions