이 후 발생하는 것입니다 다시 시작한 후 마스크 : 내 응용 프로그램을 열안드로이드 텍스트 뷰는/두 배로 미러/응용 프로그램
1) 정기적 인 작업을 수행합니다. 2) 내 응용 프로그램을 닫습니다 (조각 및 활동 삭제). 3) 응용 프로그램 서랍에서 내 응용 프로그램을 다시 엽니 다.
나는 라이프 사이클 이벤트에서 내가하고있는 일이라고 느낍니다. 그 중 누구와 마주 친 적이 있습니까? 뭐가 문제 야? 활동의
코드 (뷰 초기화) 조각 활동의
public class Play_Main extends Fragment implements IListener {
private static final String TAG = "Play_Main_Fragment";
public static CountDownLatch mCountDown = new CountDownLatch(1);
private Typeface roboto;
// Views
private TextView tv1;
private TextView pullToConnect;
private Button connectButton;
private SwipeRefreshLayout mSwipeLayout;
// Object Instances
private Play_Main mainFrag;
private MessageManager messageManager;
// Animation
private Animation fadeIn;
private Animation fadeOut;
// Fields
private String isConnectedText;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.main_ui_frame, container, false);
super.onCreateView(inflater, container, null);
mainFrag = this;
final Gson jsonMaker = new Gson();
roboto = Typeface.createFromAsset(getActivity().getAssets(), "fonts/robotot.ttf");
fadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_out);
fadeIn = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in);
messageManager = MessageManager.Instance();
// Register as a general listener
messageManager.RegisterListener(mainFrag);
// Register as the UI to interact with
messageManager.registerUI(mainFrag);
pullToConnect = (TextView) view.findViewById(R.id.pullToConnect);
pullToConnect.setTypeface(roboto);
tv1 = (TextView) view.findViewById(R.id.tv1);
tv1.setTypeface(roboto);
tv1.setText("Connect and start playing");
mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
mSwipeLayout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
XML의
public class PlayClient extends Activity {
public static Context ctx = null;
private String TAG = "PlayClient Activity";
private Fragment main;
private Fragment mSoundCloudFrag;
private MediaControlsComponent mdc;
private FragmentManager fm;
private String[] mNavigationItems;
private ListView mDrawerList;
private DrawerLayout mDrawer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
ctx = this;
// Sound Cloud fragment
mSoundCloudFrag = new SoundCloudFragment();
// Add just the main player fragment
main = new Play_Main();
mdc = new MediaControlsComponent();
fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.frameContainer, main, "main");
ft.setCustomAnimations(R.animator.fade_in, android.R.animator.fade_out);
ft.add(R.id.mediaControllerFrame, mdc);
ft.commit();
getFragmentManager().executePendingTransactions();
// Navigation Drawer
mNavigationItems = getResources().getStringArray(R.array.nav_drawer);
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
코드 : 조각의
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="100"
android:background="@color/darker"
android:orientation="vertical">
<FrameLayout
android:id="@+id/frameContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_weight="80"></FrameLayout>
<FrameLayout
android:id="@+id/mediaControllerFrame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_weight="20"></FrameLayout>
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>
XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:orientation="vertical">
<TextView
android:id="@+id/pullToConnect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="@string/pull_to_connect"
android:textColor="@android:color/white"
android:textSize="23dp" />
</LinearLayout>
<RelativeLayout
android:id="@+id/relative"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:gravity="center_horizontal"
android:padding="15dp"
android:textColor="@android:color/white"
android:textSize="30dp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
코드 (특히 XML과 실제로 레이아웃 /보기를 초기화 자바)가 말해 불가능을 보지 않고 :
savedInstanceState
가 null의 경우, 그게 당신의 활동의 첫 번째 창조 의미합니다. – zgc7009조각을 TextView에 추가하거나 바꾸시겠습니까? 특히 setRetainInstance (true)를 사용하는 경우 생성/다시 시작 메소드에 단편을 추가하는 방법으로이 문제가 발생하는 것을 보았습니다. –
코드를 추가해 주셔서 감사합니다. 도움을 감사하십시오. – Yosi199