Aufgabe 7 finished

This commit is contained in:
paul-loedige 2020-10-18 16:18:27 +02:00
parent 9256a6d0c8
commit cc555ced7f
10 changed files with 93 additions and 7 deletions

6
.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>

5
.idea/gradle.xml generated
View File

@ -10,11 +10,12 @@
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$USER_HOME$/Storage/Nextcloud/Documents/TH/Mobile Systeme (MO)/MyProject" />
<option value="$USER_HOME$/Storage/Nextcloud/Documents/TH/Mobile Systeme (MO)/MyProject/app" />
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

2
.idea/misc.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -8,6 +8,7 @@ import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@ -21,13 +22,28 @@ public class MainActivity extends AppCompatActivity {
toast_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//send toast
Toast.makeText(MainActivity.this, "Toast", Toast.LENGTH_SHORT).show();
//make intent
Intent intent = new Intent(MainActivity.this,MainActivity2.class);
startActivity(intent);
// additional data intent
EditText editText = (EditText) findViewById(R.id.text_editText);
intent.putExtra("text",editText.getText().toString());
//sent intent
startActivityForResult(intent,100);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(data != null){
String text = data.getExtras().getString("text");
EditText editText = findViewById(R.id.text_editText);
editText.setText(text);
}
}
public void call911(View view){
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:911"));
startActivity(intent);

View File

@ -1,10 +1,14 @@
package tech.loedige.myapplication;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ActionMode;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity2 extends AppCompatActivity {
@ -13,6 +17,13 @@ public class MainActivity2 extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Bundle extras= getIntent().getExtras();
if(extras!= null) {
String text = extras.getString("text");
TextView textView = (TextView) findViewById(R.id.tv_textView);
textView.setText(text);
}
}
public void makeToast(View view){
@ -20,4 +31,17 @@ public class MainActivity2 extends AppCompatActivity {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
@Override
public void finish(){
Intent dataIntent = new Intent();
EditText editText = (EditText) findViewById(R.id.text_editText);
dataIntent.putExtra("text",editText.getText().toString());
setResult(RESULT_OK,dataIntent);
super.finish();
}
public void sendResult(View view){
finish();
}
}

View File

@ -19,6 +19,13 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/text_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/toast_btn"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/toast_btn"
android:layout_width="wrap_content"
@ -32,6 +39,7 @@
android:layout_height="wrap_content"
android:text="call 911"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:onClick="call911"/>
</RelativeLayout>

View File

@ -10,7 +10,32 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/text_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/toast_btn"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/finish_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/text_editText"
android:layout_alignBottom="@id/text_editText"
android:text="Finish"
android:onClick="sendResult"/>
<Button
android:id="@+id/toast_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.android.tools.build:gradle:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -1,6 +1,6 @@
#Mon Oct 05 09:07:29 CEST 2020
#Sun Oct 18 16:17:14 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip