는 activity_main.xml는 주요 활동 클래스는이안드로이드 조각 행동 이상한
package com.example.testfragmentshoneycomb;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
first_fragment.xml처럼이
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/button_one_activity_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="First Button"
/>
<fragment
android:name="fragments.FirstFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/first_fragment" />
<Button
android:id="@+id/button_two_activity_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Second Button"
/>
</LinearLayout>
처럼이
<?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="wrap_content"
android:orientation="vertical"
android:background="@color/grey" >"
<TextView
android:id="@+id/text_view_one_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text View one" />
<TextView
android:id="@+id/text_view_two_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text View two" />
<TextView
android:id="@+id/text_view_three_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text View three" />
</LinearLayout>
FirstFragment 클래스처럼 이 같은 경우
package fragments;
import com.example.testfragmentshoneycomb.R;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FirstFragment extends Fragment{
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.first_fragment, container, false);
return view;
}
}
첫 번째 버튼 만 표시하고 다른 것은 화면에 표시하지 않습니다. activity_main.xml에서 첫 번째 단추를 제거하면 조각이 표시되지만 두 번째 단추는 표시되지 않습니다.
최소 SDK 버전은 11이며, 대상은 기본적으로있는 LinearLayout의 방향 horizontal
4.1
에 대해 알고하지 않았다 대단히 감사합니다 – Atinder