Ú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
- Azonnali notebookos kérdések órája
- Gyúrósok ide!
- Okos Otthon / Smart Home
- Elektromos autók - motorok
- Linux Mint
- Tokgyártó leplezi le újból a Galaxy S26 Ultra formáját
- gban: Ingyen kellene, de tegnapra
- Vivo X300 - kicsiben jobban megéri
- Tóth Olivér: Kedvenc processzorok:
- iPhone topik
- További aktív témák...
- BESZÁMÍTÁS! MSI B760M i7 14700K 32GB DDR5 1TB SSD RX 9070 XT 16GB Lian Li Lancool 207 Digital 750W
- ÚJ HP EliteBook 6 G1a Ryzen 5 PRO 230 4.9GHz 32GB DDR5 1TB FHD+ 16:10 már jobbik kijelző, gar 2028
- í kilenc! AKCIÓS PRECÍZIÓS KÉSZÜLÉK! 7670 i9-12950HX 32GB RAM 1TB SSD Nvidia RTX A3000 12GB 1 év gar
- Keresünk iPhone 14/14 Plus/14 Pro/14 Pro Max
- Akciós! Lenovo ThinkPad P15 Gen 1 Intel i7-10875H 32GB 512GB Nvidia Quadro RTX 3000 1 év garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


