fragment

Android: how do I prevent class variables being cleared on orientation change [duplicate]

半腔热情 提交于 2019-12-13 10:08:59
问题 This question already has answers here : Android save state on orientation change (2 answers) Closed 3 years ago . I have a main activity which has two configurations, one which will display a fragment which is locked to portrait orientation. When a button is clicked on this fragment, a fragment replaces it, however this new fragment can be displayed landscape with a second fragment side-by-side. This all works fine, however I am intercepting back-navigation in the second state so that I can

Saving bitmap from fragment to internal/external storage [closed]

走远了吗. 提交于 2019-12-13 10:01:42
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I was getting the following exception while Saving bitmap from fragment to internal/external storage 11-28 12:09:18.667: W/System.err(2620): java.io.FileNotFoundException: /storage/sdcard0/req_images/Image-296.jpg: open failed: ENOENT (No such file or directory) 11-28 12:09:18.717

Implement activity in fragment android

岁酱吖の 提交于 2019-12-13 09:25:31
问题 I'm using NavigationDrawer in my project, I have MainNavigationFragmentActivity to manage 2 fragments : HomeFragment and SettingsFragment. Now, I want to use HomeFragment to implement a activity (ManufacturerActivity) my HomeFragment class: public class HomeFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.test1, container, false

Trying to convert this activity into a fragment in android studio, no luck till now

耗尽温柔 提交于 2019-12-13 08:31:32
问题 This is my test activity and I want to convert this into a fragment. Please guide me how to convert this activity into a fragment which is inside a tabview. I am new bee in android app development and this is beyond my reach for now. Any help or suggestion is appreciated. package in.catking.catking; import android.content.Intent; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView;

Sharing Data between two Fragments of of one Activity

别说谁变了你拦得住时间么 提交于 2019-12-13 07:40:01
问题 Ive got two Fragments. One for data Input and one to display them in a ListView. But I dont know how to send data from Fragment 1 to Fragment 2... I know that I can get Data from my MainActivity to Fragment 1 with the following Code: String listElement = getActivity().getIntent().getStringExtra("com.sample.MESSAGE"); But how do I send the string from Fragment 2 to my Activity? UPDATE: I'm not quite sure if I'm doing this right... I used Harlo Holmes Tutorial (posted below) and not Ive got

Open another app within a fragment

﹥>﹥吖頭↗ 提交于 2019-12-13 07:26:27
问题 I am creating an app to run multiple tasks within a same activity. I am achieving this using fragments. Now, I want to run a game which is installed on my phone in a fragment within my activity. I tried this : PackageManager pm = getActivity().getPackageManager(); Intent intent = pm.getLaunchIntentForPackage("com.exo.drive"); getActivity().startActivityFromFragment(this, intent, getTargetRequestCode()); But this as expected opens another activity and launches the game. How do I make the game

How to refresh RecyclerView in one fragment when data changed in another fragment

十年热恋 提交于 2019-12-13 07:11:52
问题 How do I refresh the data from a local database to RecyclerView when data was successfully submitted? I use the tabs on the application. 2nd-Tab functions to submit the data, and if successful, the data will be stored in localDB . Data on localDB I will present at the 3rd-Tab . But what happens, I have to swipe 1st-Tab , then swipe to the 2nd-Tab and then swipe to the new 3rd-Tab data on my localDB successfully displayed . If the 2nd-Tab me to submit the data, then I swipe to 3rd-Tab , the

how to access fragments elements in MainActivity()?

≡放荡痞女 提交于 2019-12-13 06:49:24
问题 In my project, I want to set visibility of fragments buttons from MainActivity. But the problem is, it gives NullPointerException(). I also maked listBtn & gridBtn as static. I used below code : FirstFragment fragment = (FirstFragment)getSupportFragmentManager().findFragmentById(R.id. <frameLayout Id>); main_page_fragment.listBtn.setVisibility(View.GONE); main_page_fragment.gridBtn.setVisibility(View.GONE); 回答1: You cannot access to your fragment view from Activity class because activity uses

Android Layout Fragment/Activity Confusion

余生颓废 提交于 2019-12-13 05:21:30
问题 I am making my first android application with the ActionBarSherlock. The application will always have an action bar consisting of 3 tabs (first tab selected by default). The app could be extended for use with a tablet. I have been searching the web, and following the android development guides, however I am finding a few things confusing. The first tab screen will be a list view with a list of items, onitemselected should send the user to a screen which features more details about that item.

communication between fragments of fragment tab host

六月ゝ 毕业季﹏ 提交于 2019-12-13 05:19:09
问题 I am implementing tabs using FragmentTabHost of v4 support library. My first tab contains the list of items.When I click on list item it should move to tab 2. My second tab shows the description of the list item.So I need to pass the list of the first tab and the index of list item clicked to the second tab. I am currently using getters and setters at application level. But is there any other way to do so? What is the best way to do this? First fragment-Tab-0 @Override public void onAttach