Új hozzászólás Aktív témák
-
automATIc
csendes tag
public class MainActivity extends AppCompatActivity {
EditText editText;
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.editText);
textView = (TextView) findViewById(R.id.textView);
textView.setVisibility(View.GONE);
}
public void writeMessage(View view){
String Message = editText.getText().toString();
String file_name = "user_data";
try {
FileOutputStream fileOutputStream = openFileOutput(file_name,MODE_PRIVATE);
fileOutputStream.write(Message.getBytes());
fileOutputStream.close();
Toast.makeText(getApplicationContext(),"Message saved",Toast.LENGTH_LONG).show();
editText.setText("");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void readMessage(View view){
try {
String Message;
FileInputStream fileInputStream = openFileInput("user_data");
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuffer stringBuffer = new StringBuffer();
while ((Message=bufferedReader.readLine())!=null)
{
stringBuffer.append(Message +"\n");
}
textView.setText(stringBuffer.toString());
textView.setVisibility(View.VISIBLE);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void showClick(View view){
if (view.getId() == R.id.showTextButton);
Intent sb = new Intent();
sb.setClass(this, ReadText.class);
startActivity(sb);
}
}Kb. itt tartok most. Azt szeretném, hogy az Activity mutassa a beírt szövegemet.
Egyelőre ezt az "adatbázist" tudtam kiCopyzni ami működik is
[ Módosította: Karma ]
Új hozzászólás Aktív témák
- Honda topik
- bambano: Bambanő háza tája
- Iqos cigaretta
- Formula-1
- NFL és amerikai futball topik - Spoiler veszély!
- Mr Dini: Mindent a StreamSharkról!
- CADA, Polymobil, és más építőkockák
- OnePlus 15 - van plusz energia
- Kínai és egyéb olcsó órák topikja
- PROHARDVER! feedback: bugok, problémák, ötletek
- További aktív témák...
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest


