Tag android-fragments

[Solved] How to parse JSON data into fragments?

you can parse like this: List<RidesData> ridesDatas; /* this is should be parcelable */ private void setupViewPager(ViewPager viewPager) { ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); adapter.addFragment(FragmentAbout.newInstance(ridesDatas), “ABOUT”); adapter.addFragment(FragmentPointOfInterest.newInstance(ridesDatas),”POI”); viewPager.setAdapter(adapter); } and set constructure to each fragment like this: FragmentAbout.class public static…

[Solved] Change Activities’ Fragment Inside the Fragment

Use below method public static void openFragment(FragmentManager manager, Fragment targetFragment) { try { String fragmentName = targetFragment.getClass().getName(); manager.popBackStack(); manager.beginTransaction() .replace(R.id.frameLayout, targetFragment, fragmentName) .addToBackStack(fragmentName) .commit(); } catch (Exception e) { e.printStackTrace(); } } call this method each time when you are…

[Solved] How to replace setContentView in a fragment for SQLdatabase?

First, delete this from your onCreate(): setContentView(R.layout.fragment_section_number1); Next, move the following from your onCreate(): myDb = new DatabaseHelper(this); editName = (EditText) rootview.findViewById(R.id.editText_Name); editSurname = (EditText) rootview.findViewById(R.id.editText_Surname); editBalance = (EditText) rootview.findViewById(R.id.editText_Balance); btnAddData = (Button) rootview.findViewById(R.id.button_add); btnviewAll = (Button) rootview.findViewById(R.id.button_viewAll); AddData(); viewAll();…

[Solved] ListView returning null using Fragment

This is happening because you are using the wrong View variable to find the ListView. ListView lv = (ListView) view.findViewById(R.id.lvAlerts); The view variable here refers to: public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { You need to…

[Solved] Register Broadcast receiver in Fragment PageViewer [closed]

No need to register fragment into manifest you can register receiver from fragment like this way private ScreenTimeOutReceiver mScreenTimeOutReceiver; mScreenTimeOutReceiver = new ScreenTimeOutReceiver(); registerReceiver(mScreenTimeOutReceiver, filter); 4 solved Register Broadcast receiver in Fragment PageViewer [closed]

[Solved] Navigating from an activity to a fragment [duplicate]

You can use from switching from Fragment to Activity-: Implement this code on BackPressed-: @Override public void onBackPressed() { super.onBackPressed(); YourFragment mapFragment = new YourFragment(); FragmentManager manager = getFragmentManager(); manager.beginTransaction().replace(R.id.landlord_apartment, mapFragment, mapFragment.getTag()).commit(); } While moving from Fragment to Activity-: startActivity(new…

[Solved] Choosing language at startup

If I understand you correctly you wish to display that activity only when the user runs the app for the first time. Well, here’s what you can do: 1) Get a handle to a SharedPreference. This is to store if…

[Solved] How to create layout like in this image? [closed]

Not sure is this what you want. You may try. <RelativeLayout xmlns:android=”” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal” android:gravity=”start” android:background=”@android:color/white” android:padding=”12dp”> <ImageView android:id=”@+id/image” android:layout_width=”80dp” android:layout_height=”70dp” android:layout_centerVertical=”true” android:layout_gravity=”left”/> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_toRightOf=”@+id/image” android:layout_centerVertical=”true” android:paddingLeft=”6dp” android:orientation=”vertical” android:layout_alignParentRight=”true” android:layout_alignParentEnd=”true”> <LinearLayout android:id=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView android:id=”@+id/name”…

[Solved] how to replace some character’s of String

You can use string replace method. see below String number = +9231235410; String newNumber = number.replace(“+92″,”0”); EDIT: this one is base on your code private String modifyNumber(String num) { if (num.startsWith(“+92”)) { num = num.replaceFirst(“\\+(92)”, “0”);} return num;} Note: In…