Ich habe eine Navigationsschublade und gegen jedes Element in der Schublade gibt es eine Fragmentseite. Ich möchte Tabbed Swipe innerhalb eines Fragments implementieren. Wie mache ich das. Hier ist mein Code, nachdem ich auf eine Fragmentseite der Navigationsleiste geklickt habe. Ich möchte die Tabbed-Ansicht innerhalb dieser Seite implementieren. Wie ist der Weg?Schieberegler in Fragment implementieren
//-Code
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
*/
public class SalesFragment extends Fragment {
private Toolbar mToolbar;
public SalesFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_sales, container, false);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.toolbar_menu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.add_user) {
return true;
}
if (id == R.id.barcode_scanner) {
return true;
}
if (id == R.id.search_overflow) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
// und hier ist das Layout XML-Seite
<FrameLayout 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"
tools:context="com.soumya.possystem.SalesFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Sales page"
android:textSize="40dp"/>
</FrameLayout>
Nein Nein !! Bitte lies meine Frage. Ich möchte es innerhalb einer Fragmentseite implementieren, die bereits erstellt wurde. Bitte sehen Sie meinen Code. –
Worauf Sie sich beziehen, ist eine Aktivität, aber ich muss sie in einem Fragment implementieren. –