null 포인터를 던지는 setContentView에 문제가 있습니다.OnContentView OnLongClick Listener
내 메인 프레임에는 화면의 약 50 %를 차지하는 작은 SurfaceView가 있습니다. 오랫동안 클릭하면 SurfaceView가 전체 화면으로 전환되는 방법을 구현하고 싶었습니다. 나는 이것을 이렇게했다 :
final FrameLayout frame = (FrameLayout) findViewById(R.id.frame_layout);
frame.setOnLongClickListener(new OnLongClickListener() {
boolean clicked = false;
@Override
public boolean onLongClick(View v) {
if (clicked){
clicked = false;
(MyActivity.this).setContentView(R.layout.main);
} else {
clicked = true;
(MyActivity.this).setContentView(R.layout.fullScreen);
}
return true;
}
});
이 문제를 해결하는 방법을 누군가가 도와 줄 수 있습니까?
인사말
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
android:orientation="vertical"
android:weightSum="1"
android:background="@drawable/background_new" >
<TextView
android:text="@string/measures"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/text_measures"
android:textColor="#ff444444"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/>
<ImageButton
android:contentDescription="@string/desc_edge"
android:layout_toRightOf="@id/text_measures"
android:id="@+id/edges_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/edges_black"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="30dp"
android:onClick="edge_handler"
android:background="@null"
/>
<FrameLayout
android:background="@xml/border"
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginBottom="35dp"
android:layout_marginRight="200dp"
android:layout_marginTop="80dp"
android:layout_below="@id/text_measures"
>
</RelativeLayout>
나는 그것이 FrameLayout이처럼 보이는 알고 있지만 그것은 다른 사람에 의해 수행되었다 속지 해달라고 실제로 서피스 뷰 SurfaceView입니다.
가 될 때까지 시각적 인 충격이없는 내 문제 – Sameer
참조 * after * onCreate() 가 반환됩니다. 두 번 호출하면 그물은 사용자가 초만 볼 수 있습니다. –
된 setContentView()를 해결하기 위해 그 didnt 한 도움말을 어떻게 든이 https://groups.google.com/forum/?fromgroups#!topic/android-developers/wj4uc0J9yT0 – SALMAN