Aufgabe 7 finished
This commit is contained in:
parent
fbfedab3aa
commit
2a718faa9d
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -9,6 +9,7 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Uebung7und10">
|
||||
<activity android:name=".ResultActivity"></activity>
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.ploedige.uebung7und10;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
@ -11,4 +16,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
Log.v("MainActivity","requestCode:" + requestCode + "ResultCode" + resultCode);
|
||||
TextView result = (TextView) findViewById(R.id.result_tv);
|
||||
EditText editText = (EditText) findViewById(R.id.message_etxt);
|
||||
|
||||
result.setText("Result: " + data.getExtras().getString("text"));
|
||||
editText.setText("Result: " + data.getExtras().getString("text"));
|
||||
}
|
||||
|
||||
public void submit(View view){
|
||||
Intent intent = new Intent(this, ResultActivity.class);
|
||||
EditText editText = (EditText) findViewById(R.id.message_etxt);
|
||||
intent.putExtra("text",editText.getText().toString());
|
||||
startActivityForResult(intent,100);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.ploedige.uebung7und10;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class ResultActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_result);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if(extras != null){
|
||||
EditText editText = (EditText) findViewById(R.id.message_etxt);
|
||||
editText.setText(extras.getString("text"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish(){
|
||||
Intent dataIntent = new Intent();
|
||||
EditText editText = (EditText) findViewById(R.id.message_etxt);
|
||||
dataIntent.putExtra("text",editText.getText().toString());
|
||||
setResult(RESULT_OK,dataIntent);
|
||||
super.finish();
|
||||
}
|
||||
|
||||
public void sendResult(View view){
|
||||
finish();
|
||||
}
|
||||
}
|
@ -6,13 +6,36 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
<EditText
|
||||
android:id="@+id/message_etxt"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
android:minWidth="30mm"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/submit_btn"
|
||||
android:text="Submit"
|
||||
android:onClick="submit"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/message_etxt"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result_tv"
|
||||
android:textSize="5mm"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintBottom_toTopOf="@id/message_etxt"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
32
app/src/main/res/layout/activity_result.xml
Normal file
32
app/src/main/res/layout/activity_result.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ResultActivity"
|
||||
android:background="@color/teal_200">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/message_etxt"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="30mm"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/sendResult_btn"
|
||||
android:text="Send Result"
|
||||
android:onClick="sendResult"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/message_etxt"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user