getstring

MonoGame Key Pressed String

感情迁移 提交于 2019-12-04 14:57:28
In MonoGame, how can I read which keyboard key is pressed in the form of a String? I have tried String pressedKey = Keyboard.GetState().ToString(); , but it gives me "Microsoft.Xna.Framework.Input.KeyboardState". In games, you typically think of keys as buttons that have state rather than strings because you are usually checking if a button is up or down to move a character around, shoot, jump, etc. As others have said, you said you should use IsKeyDown and IsKeyUp if you already know what keys you want to test. However, sometimes you just want to know what keys are being pressed. For that,

how to pass extra intent to two activities

孤人 提交于 2019-12-04 05:14:47
问题 i have an app that on the first activity asks the persons name on the second page it displays the name in a sentence i want to use the name in the third fourth or 9th activity how do i properly declare it (public?) and call it when and where ever i need it? this is my code sending it Main public class MainActivity extends Activity { Button ok; EditText name; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

Why might Resources.getString() intermittently return strings from the wrong locale?

[亡魂溺海] 提交于 2019-12-02 19:09:37
I have an Android application with English strings in values/strings.xml. For each string in that file, I have an entry in values-ja/strings.xml with the Japanese translation of that string. If I set the emulator, a Nexus One or Nexus S to Japanese, the UI shows Japanese text throughout. Most of the time. Sometimes, some portion of the UI will appear in English, even though the current locale is ja-JP. For instance, I wrote this test code in the onCreate() method of one of my activities: Log.e(TAG, "Default locale = '" + Locale.getDefault().toString() + "'"); Log.e(TAG, "My string = '" +

android application crashes at the getString() line

孤街浪徒 提交于 2019-12-02 01:50:26
this is my strings.xml <resources> <string name="alert_internet">out</string> </resources> I am trying to call this string in my main activity like below: final String net = getString(R.string.alert_internet); I also checked my R.java file too, the int of 'alert_internet' exists. But for some reason whenever I launch the application it crashes down to the ground. What am I doing wrong trying to get a simple string? this is my log.cat 09-23 13:17:33.092: E/AndroidRuntime(21302): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573) 09-23 13:17:33.092: E/AndroidRuntime

java resultset.getstring(“col_name”) query

雨燕双飞 提交于 2019-12-01 00:43:58
I have a simple query regarding ResultSet.getString() method in java for JDBC. Suppose the value in the Database column is having a \ which is javas escape character e.g. \n or \t etc. When i retrieve the value as getString() i see one more escape character is getting added and the actual meaning of this \n is now a string literal only. So i had to unescape java and then use it properly. String s= rs.getString("col_name"); When s contains `\n': System.out.println(s) output: \n After unescaping java using apache common StringEscapeUtils output: System.out.println("hi"+s+"hello"); hi hello My

Getting null terminated string from System.Text.Encoding.Unicode.GetString

[亡魂溺海] 提交于 2019-11-29 13:39:30
I have an array of bytes that I receive from an external entity. It is a fixed size. The bytes contain a unicode string, with 0 values to pad out the rest of the buffer: So the bytes might be: H \0 E \0 L \0 L \0 \0 \0 \0 \0 \0 ... etc I'm getting that buffer and converting it to a string like so: byte[] buffer = new byte[buffSize]; m_dataStream.Read(buffer, 0, buffSize); String cmd = System.Text.Encoding.Unicode.GetString(buffer); What I get back is a string that looks like this: "HELLO\0\0\0\0\0\0\0\0..." How can I tell GetString to terminate the string at the first Unicode null (ie so I