android-fragmentactivity

Android Fragments and Activities

不打扰是莪最后的温柔 提交于 2019-12-11 02:55:49
问题 referring at the diagram below: http://developer.android.com/guide/components/fragments.html Could someone please please explain why Google suggests to use 2 separate activities on a Phone and a single activity on a Tablet? If I have code in activity A to manage Fragment B (for a Tablet) why should I repeat the same code in Activity B for a phone? It seems that for a Phone I can still use 1 activity as well (only activity A) and replace fragments, this could reduce redundant code? Thanks. 回答1

one Fragment to another Fragment on Button click

筅森魡賤 提交于 2019-12-11 02:29:30
问题 I have learned how to change the fragment activity from one to another (all are fragment activities) on button click but now I am having issue with multiple button on same fragment. only first button id works. I have more than one button and each button has different fragment activity. need help package com.test.fragmentation; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction;

How to implement Android Fragment Transaction .add syntax error

Deadly 提交于 2019-12-11 01:16:21
问题 I'm would like to make my Android application use Fragment Transactions, so that I can switch between various Fragments display their associated lists. My application worked fine prior to attempting to convert to just Fragment Transactions. In my initial activity_main.xml, I removed the android:name="com.birdsall.peter.chap.ChapterFragment", it is my understanding you can't use xml defined fragments with fragment transactions. 1) I can't seem to get the .add() within getSupportFragmentManager

MapFragment Styled as Dialog causes TextView to be transparent

可紊 提交于 2019-12-11 00:55:35
问题 Here's the setup: I'm constructing and displaying Activities that are styled as centered Dialogs. This is to show hierarchical content that shouldn't be full-screen on the device. One type of content is a map. So i've successfully loaded a MapFragment into a Dialog-styled FragmentActivity. This works really well. The problem is when I attempt to place a new TextView (acting as a custom title bar) above the map. The issue is that the TextView's content seems to become transparent and the

FragmentManager, LocalActivityManager and TabHost.setup()

谁说我不能喝 提交于 2019-12-11 00:27:19
问题 Ok, I have a class that inherits from FragmentManager. Inside this class I have a FragmentPagerAdapter that create some fragment tabs and insert in my TabHost. The code compiles fine and works. I put some parts of theses classes below. I'm using to do this ths android supprt package v4 public class TabMenu extends FragmentActivity implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener{ ... @Override public void onCreate(Bundle savedInstanceState){ super.onCreate

How to implement a menuitem click listener inside a fragment in android

血红的双手。 提交于 2019-12-10 22:56:06
问题 I have MenuItems in the ActionBar and I am using Fragments inside ViewPager. Now I would like to handle onMenuItemClickListener event inside my fragment. It works fine inside Main Activity. But not inside Fragments. And also it doesn't fetch any error. Here is the methods that I tried. Both works fine inside Activity. First method: public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.grid_view); item.setOnMenuItemClickListener(new OnMenuItemClickListener() {

How to Create option menu in FragmentActivity?

江枫思渺然 提交于 2019-12-10 20:48:08
问题 Hi Below is the code I am using to create option menu in my FragmentActivity :- @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.main, menu); return true; } // Menu options to set and cancel the alarm. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // When the user clicks START ALARM, set the alarm. case R.id.start_action: alarm.setAlarm(this); return true; // When the user

How to set a Text in the TextView of the second fragment by pushing on the button

北战南征 提交于 2019-12-10 18:33:33
问题 I have 1 activity with 2 fragments in an Android app. On the first fragment, I did put a button (btnA). On the second I putt a TextView (txtB). How can I set a Text in the TextView of the second fragment by pushing on the button on the first activity? Thx, I'm new to android app development JoskXP 回答1: Well you could do something like this: In your activity, provide public links to both of your fragments: public FragmentNumberOne getFragmentOne() { return fragOne; } public FragmentNumberTwo

Android with Kotlin error when use RecyclerView in Fragment

喜你入骨 提交于 2019-12-10 13:32:27
问题 I have error said this: Process: com.example.yudha.kotlinauth, PID: 16435 java.lang.IllegalStateException: video_recyclerview must not be null at com.example.yudha.kotlinauth.fragments.VideoFragment.onCreateView(VideoFragment.kt:30) RecyclerView Adapter: class MainAdapter : RecyclerView.Adapter<CustomViewHolder>(){ val videoTitles = listOf("First title", "Second", "3rd", "Moore Title") //number of item override fun getItemCount(): Int { return videoTitles.size } override fun

Fragment onResume not called

折月煮酒 提交于 2019-12-10 12:57:32
问题 I am having 4 (let's say 1,2,3 & 4) fragments. And at a time any one of them will be visible to User. In 2nd fragment I want to do something when user is coming on it. Now when User navigated to 3rd fragment & hits the back button, I want to run a some code. My problem is onResume is not getting called when user hits the back button & come to 2nd fragment. 回答1: I recently bumped into the same problem, I know that its too late, but just in case some one else is looking for this, here's my