Browse Source

added new Project ueberwachungssystem

ko^2
Oliver Kleinecke 1 year ago
parent
commit
5f7e2a43f2

+ 52
- 6
app/src/main/java/de/oklein/android/ueberwachungssystem/MainActivity.java View File

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;
@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) {
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();
} }
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.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; return view;
} }
public static Fragment1 erstellen(String text) { public static Fragment1 erstellen(String text) {
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);
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; return view;
} }
public static Fragment2 erstellen(String text) { public static Fragment2 erstellen(String text) {
} }
} }
} }

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");
}
}
}
} }

+ 53
- 27
app/src/main/res/layout/activity_main.xml View File

android:background="@android:color/holo_orange_light"> android:background="@android:color/holo_orange_light">


<Button <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Zeige Fragment 1"
android:onClick="onClickZeigeFragment1"/>
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/btn2"
android:layout_toLeftOf="@id/btn2"
android:text="Audio"
android:onClick="onClickZeigeFragment1"/>


<Button <Button
android:id="@+id/btnFordereRechte"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/button1"
android:text="Zeige Fragment 2"
android:onClick="onClickZeigeFragment2"/>
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:text="Kamera"
android:onClick="onClickZeigeFragment2"/>


<Button <Button
android:id="@+id/buttonEntferneFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnFordereRechte"
android:text="Entferne Fragment"
android:onClick="onClickEntferneFragment"/>
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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 <FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/buttonEntferneFragment">
</FrameLayout>
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnAufnahme">
</FrameLayout>


</RelativeLayout> </RelativeLayout>

+ 10
- 3
app/src/main/res/layout/fragment1.xml View File

<?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"
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>

+ 12
- 9
app/src/main/res/layout/fragment2.xml View File

android:orientation="vertical" android:orientation="vertical"
android:background="@android:color/holo_blue_light" > 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> </LinearLayout>

+ 22
- 0
app/src/main/res/layout/fragment3.xml View File

<?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…
Cancel
Save