added new Project ueberwachungssystem
This commit is contained in:
parent
07f60f974b
commit
5f7e2a43f2
@ -11,9 +11,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private Fragment aktuellesFragment;
|
||||
@ -23,7 +23,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setTitle( this.getClass().getSimpleName());
|
||||
setTitle(this.getClass().getSimpleName());
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
public void onClickZeigeFragment1(View view) {
|
||||
@ -37,6 +37,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
zeigeFragment(Fragment2.erstellen("Fragment 2 wurde angeklickt"));
|
||||
}
|
||||
|
||||
public void onClickZeigeFragment3(View view) {
|
||||
Button button = (Button) view;
|
||||
log(button.getText() + " ausgewählt");
|
||||
zeigeFragment(Fragment3.erstellen("Fragment 3 wurde angeklickt"));
|
||||
}
|
||||
|
||||
public void onClickEntferneFragment(View view) {
|
||||
entferneFragment();
|
||||
}
|
||||
@ -66,8 +72,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
log("onCreateView");
|
||||
View view = inflater.inflate(R.layout.fragment1, container, false);
|
||||
TextView textView = (TextView) view.findViewById(R.id.textView);
|
||||
textView.setText(text);
|
||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
||||
Sensor.setText(text);
|
||||
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||
Alarm.setText(text);
|
||||
return view;
|
||||
}
|
||||
public static Fragment1 erstellen(String text) {
|
||||
@ -99,8 +107,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
log( "onCreateView" );
|
||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
||||
EditText editText = (EditText) view.findViewById(R.id.editText1);
|
||||
editText.setText(text);
|
||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
||||
Sensor.setText(text);
|
||||
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||
Alarm.setText(text);
|
||||
return view;
|
||||
}
|
||||
public static Fragment2 erstellen(String text) {
|
||||
@ -122,4 +132,40 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Fragment3 extends Fragment {
|
||||
private String text;
|
||||
private final static String KEY_TEXT = "KEY_TEXT" ;
|
||||
private void log(String nachricht) {
|
||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
log( "onCreateView" );
|
||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
||||
Sensor.setText(text);
|
||||
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||
Alarm.setText(text);
|
||||
return view;
|
||||
}
|
||||
public static Fragment3 erstellen(String text) {
|
||||
Fragment3 fragment = new Fragment3();
|
||||
Bundle b = new Bundle();
|
||||
b.putString(KEY_TEXT, text);
|
||||
fragment.setArguments(b);
|
||||
return fragment;
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
text = args.getString(KEY_TEXT);
|
||||
log("onCreate: text=" + text);
|
||||
} else {
|
||||
log("onCreate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,30 +7,56 @@
|
||||
android:background="@android:color/holo_orange_light">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/btn1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Zeige Fragment 1"
|
||||
android:layout_alignBottom="@id/btn2"
|
||||
android:layout_toLeftOf="@id/btn2"
|
||||
android:text="Audio"
|
||||
android:onClick="onClickZeigeFragment1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnFordereRechte"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/btn2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/button1"
|
||||
android:text="Zeige Fragment 2"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Kamera"
|
||||
android:onClick="onClickZeigeFragment2"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonEntferneFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/btn3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/btnFordereRechte"
|
||||
android:text="Entferne Fragment"
|
||||
android:layout_alignBottom="@id/btn2"
|
||||
android:layout_toRightOf="@id/btn2"
|
||||
android:text="Bewegung"
|
||||
android:onClick="onClickZeigeFragment3"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSensorWeg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@+id/btn1"
|
||||
android:text="Entferne Sensordarstellung"
|
||||
android:onClick="onClickEntferneFragment"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnAufnahme"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/btnSensorWeg"
|
||||
android:text="Aufnahme"
|
||||
android:onClick="onClickEntferneFragment"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnWiedergabe"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/btnAufnahme"
|
||||
android:layout_below="@+id/btnSensorWeg"
|
||||
android:text="Wiedergabe"
|
||||
android:onClick="onClickEntferneFragment"/>
|
||||
|
||||
<FrameLayout
|
||||
@ -38,7 +64,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/buttonEntferneFragment">
|
||||
android:layout_below="@+id/btnAufnahme">
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
@ -7,9 +7,16 @@
|
||||
android:background="@android:color/holo_green_light">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:id="@+id/Sensor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/Alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/Sensor"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
</RelativeLayout>
|
@ -6,14 +6,17 @@
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/holo_blue_light" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:ems="10"
|
||||
android:textStyle="italic"
|
||||
android:inputType="textMultiLine" >
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
<TextView
|
||||
android:id="@+id/Sensor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/Sensor"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
</LinearLayout>
|
22
app/src/main/res/layout/fragment3.xml
Normal file
22
app/src/main/res/layout/fragment3.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:background="@android:color/holo_blue_light" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Sensor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/Sensor"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user