SharedPreferences sPref = getPreferences(MODE_PRIVATE); Editor ed = sPref.edit(); ed.putString(LOGIN,login.getText().toString() ); ed.putString(PASSORD,password.getText().toString() ); ed.commit();
SharedPreferences sPref = getPreferences(MODE_PRIVATE); String login = sPref.getString(LOGIN, ""); String password = sPref.getString(PASSORD, "");
{"rooms":["room1","room2","room3","room4"]}
// JSONObject json = new JSONObject(result); // JSONArray jsa = json.getJSONArray("rooms"); // ListView roomsLv = (ListView) findViewById(R.id.roomsLv); // json String[] StringArray = new String[jsa.length()]; for(int i = 0; i < jsa.length(); i++) { StringArray[i] = jsa.getString(i); } // ArrayAdapter<String> adapter = new ArrayAdapter<String>(RoomsActivity.this,android.R.layout.simple_list_item_1, StringArray); // roomsLv.setAdapter(adapter);
roomsLv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view,int position, long id) { Intent intent = new Intent(RoomsActivity.this, RoomSetActivity.class); intent.putExtra("roomName", parent.getItemAtPosition(position).toString()); startActivity(intent); } });
String roomName = getIntent().getExtras().getString("roomName");
Source: https://habr.com/ru/post/165641/
All Articles