在tabview中的片段

问题描述:

我正在创建一个标签视图,当点击一个按钮时,它必须移动到另一个屏幕,当我尝试使用上面的代码实现它时,它将更改为另一个屏幕,但按钮仍然可见,并显示下一个屏幕我想下一个屏幕应该覆盖整个屏幕在tabview中的片段

public class Tab1Fragment extends Fragment { 
LinearLayout mLayout; 
/** (non-Javadoc) 
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,  android.view.ViewGroup, android.os.Bundle) 
*/ 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
    Bundle savedInstanceState) { 

if (container == null) { 


    return null; 
} 

LinearLayout theLayout = (LinearLayout)inflater.inflate(R.layout.tab_frag1_layout, container, false); 

     // Register for the Button.OnClick event 

     Button b = (Button)theLayout.findViewById(R.id.button1); 

     b.setOnClickListener(new View.OnClickListener() { 



      @Override 

      public void onClick(View v) { 

       Fragment mFragment = new third_fragment_view(); 
       android.support.v4.app.FragmentTransaction ft = getFragmentManager().beginTransaction(); 

       ft.replace(R.id.container, mFragment); 
       ft.addToBackStack(null); 
       ft.commit(); 


      } 

     }); 

return theLayout; 

} 
} 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:background="#00bfff" 
android:id="@+id/container1" > 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Button" /> 

</LinearLayout> 

enter image description here

用户界面,以覆盖整个屏幕dn't使用Fragments.Use意图

b.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
     Intent intent=new Intent(); 
     intent.setClass(thisactivity.class,targetactivity.class); 
     startActivity(intent); 
     } 
    }); 
+0

但我想打开该行为ivity在相同的标签,如果我使用,如你所说那么它会打开它在一个新的窗口不在我的标签下 – Ghouse 2012-02-21 11:24:20

+0

Ok.On Cliking the Button应该显示什么。根据你的要求 – user1213202 2012-02-21 11:30:02

+0

你需要显示一个emptyScreen出button.is它correcet?这是你的要求r不? – user1213202 2012-02-21 11:33:47