Resolve string concatenation in setText

Set args in strings.xml value
This commit is contained in:
Adeel Zafar 2019-08-15 04:03:38 +05:00
parent 089dc8b00d
commit 50e072bf18
2 changed files with 5 additions and 5 deletions

View File

@ -97,9 +97,9 @@ public class ZimHostActivity extends BaseActivity implements
setUpToolbar();
if (savedInstanceState != null) {
ip = savedInstanceState.getString(IP_STATE_KEY);
serverTextView.setText(
getString(R.string.server_started_message) + " " + savedInstanceState.getString(
IP_STATE_KEY));
getString(R.string.server_started_message, ip));
startServerButton.setText(getString(R.string.stop_server_label));
startServerButton.setBackgroundColor(getResources().getColor(R.color.stopServer));
}
@ -259,7 +259,7 @@ public class ZimHostActivity extends BaseActivity implements
if (isServerStarted) {
ip = getAddress();
ip = ip.replaceAll("\n", "");
serverTextView.setText(getString(R.string.server_started_message) + " " + ip);
serverTextView.setText(getString(R.string.server_started_message, ip));
startServerButton.setText(getString(R.string.stop_server_label));
startServerButton.setBackgroundColor(getResources().getColor(R.color.stopServer));
}
@ -464,7 +464,7 @@ public class ZimHostActivity extends BaseActivity implements
@Override public void serverStarted(String ip) {
this.ip = ip;
serverTextView.setText(getString(R.string.server_started_message) + " " + this.ip);
serverTextView.setText(getString(R.string.server_started_message, this.ip));
startServerButton.setText(getString(R.string.stop_server_label));
startServerButton.setBackgroundColor(getResources().getColor(R.color.stopServer));
isServerStarted = true;

View File

@ -54,7 +54,7 @@
<string name="start_server_label">Start server</string>
<string name="stop_server_label">Stop server</string>
<string name="server_started_title">Server started</string>
<string name="server_started_message">Enter this ip address into your browser to access the server</string>
<string name="server_started_message">Enter this ip address into your browser to access the server %s</string>
<string name="error_filenotfound">Error: The selected ZIM file could not be found.</string>
<string name="error_fileinvalid">Error: The selected file is not a valid ZIM file.</string>
<string name="error_articleurlnotfound">Error: Loading article (Url: %1$s) failed.</string>