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.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private Fragment aktuellesFragment;
|
private Fragment aktuellesFragment;
|
||||||
@ -23,7 +23,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setTitle( this.getClass().getSimpleName());
|
setTitle(this.getClass().getSimpleName());
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
}
|
}
|
||||||
public void onClickZeigeFragment1(View view) {
|
public void onClickZeigeFragment1(View view) {
|
||||||
@ -37,6 +37,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
zeigeFragment(Fragment2.erstellen("Fragment 2 wurde angeklickt"));
|
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) {
|
public void onClickEntferneFragment(View view) {
|
||||||
entferneFragment();
|
entferneFragment();
|
||||||
}
|
}
|
||||||
@ -66,8 +72,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||||
log("onCreateView");
|
log("onCreateView");
|
||||||
View view = inflater.inflate(R.layout.fragment1, container, false);
|
View view = inflater.inflate(R.layout.fragment1, container, false);
|
||||||
TextView textView = (TextView) view.findViewById(R.id.textView);
|
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
||||||
textView.setText(text);
|
Sensor.setText(text);
|
||||||
|
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||||
|
Alarm.setText(text);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
public static Fragment1 erstellen(String text) {
|
public static Fragment1 erstellen(String text) {
|
||||||
@ -99,8 +107,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||||
log( "onCreateView" );
|
log( "onCreateView" );
|
||||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
View view = inflater.inflate(R.layout.fragment2, container, false );
|
||||||
EditText editText = (EditText) view.findViewById(R.id.editText1);
|
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
||||||
editText.setText(text);
|
Sensor.setText(text);
|
||||||
|
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||||
|
Alarm.setText(text);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
public static Fragment2 erstellen(String text) {
|
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,38 +7,64 @@
|
|||||||
android:background="@android:color/holo_orange_light">
|
android:background="@android:color/holo_orange_light">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button1"
|
android:id="@+id/btn1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignBottom="@id/btn2"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_toLeftOf="@id/btn2"
|
||||||
android:text="Zeige Fragment 1"
|
android:text="Audio"
|
||||||
android:onClick="onClickZeigeFragment1"/>
|
android:onClick="onClickZeigeFragment1"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnFordereRechte"
|
android:id="@+id/btn2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_below="@+id/button1"
|
android:layout_alignParentTop="true"
|
||||||
android:text="Zeige Fragment 2"
|
android:text="Kamera"
|
||||||
android:onClick="onClickZeigeFragment2"/>
|
android:onClick="onClickZeigeFragment2"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonEntferneFragment"
|
android:id="@+id/btn3"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignBottom="@id/btn2"
|
||||||
android:layout_below="@+id/btnFordereRechte"
|
android:layout_toRightOf="@id/btn2"
|
||||||
android:text="Entferne Fragment"
|
android:text="Bewegung"
|
||||||
android:onClick="onClickEntferneFragment"/>
|
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
|
<FrameLayout
|
||||||
android:id="@+id/frame"
|
android:id="@+id/frame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_below="@+id/buttonEntferneFragment">
|
android:layout_below="@+id/btnAufnahme">
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
@ -7,9 +7,16 @@
|
|||||||
android:background="@android:color/holo_green_light">
|
android:background="@android:color/holo_green_light">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/Sensor"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
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:orientation="vertical"
|
||||||
android:background="@android:color/holo_blue_light" >
|
android:background="@android:color/holo_blue_light" >
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/editText1"
|
android:id="@+id/Sensor"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:ems="10"
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
android:textStyle="italic"
|
|
||||||
android:inputType="textMultiLine" >
|
<TextView
|
||||||
<requestFocus />
|
android:id="@+id/Alarm"
|
||||||
</EditText>
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/Sensor"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</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