From the Official Android development Reference: Public void setArguments (Bundle args) Supply the construction arguments for this fragment. This can only be called before the fragment has been attached to its activity; that is, you should call it immediately after constructing the fragment. The arguments supplied here will be retained...
android,android-fragments,android-activity
Although you don't necessarily have to use the support library for fragment support if you're targeting SDK 11 or higher, it's worth using to get material styles from Lollipop on earlier versions of Android. This will give your app a more consistent look and feel. Do not mix fragments with...
android,listview,android-fragments
The mistake you have done in onItemClick() in this line : change fragmentTransaction.replace(R.layout.fragment_mwl_associations, myFragment); to fragmentTransaction.replace(R.id.container, myFragment); Here, you entered the wrong layout id for replace, instead add the FrameLayoutcontainer id R.id.container which you have used to add the fragment in your MainActivity.java. reference links would be more helpful: Fragments...
android,android-layout,android-fragments
Try modifying the following line in you .xml file android:dropDownWidth="match_parent" to android:dropDownWidth="300dp" or wrap_content Hope this should help !...
android,android-fragments,android-edittext,android-view,android-textview
You can use a regular expression to do that. Use code like this one: if(Pattern.matches("^\\w+\\s\\w+\\s\\w+$", mSearchView.getText().toString())) Also make sure to check if mSearchView.getText() is not null - you probably will get a NullReferenceException with a blank EditText content. In the end you may want to create a method like this...
android,android-fragments,android-viewpager
As to your first question you can call setOffscreenPageLimit(2) method on your ViewPager right after initializing it. By default it is set to 1 that means that adapter creates one page which is on the screen right now and one that is next.
If your Activity extends android.app.Activity you don't need to override onBackPressed(). It will pop your fragments from back stack automatically.
android,eclipse,android-fragments,android-tabs,oncreate
From Android Documentation about FragmentPagerAdapter : This version of the pager is best for use when there are a handful of typically more static fragments to be paged through, such as a set of tabs. The fragment of each page the user visits will be kept in memory, though its...
Use android:id="@+id/tvNewText" to resolve the error.
android,android-fragments,recyclerview,fragmentpageradapter
I finally solved my problem and here is how : 1 - Change FragmentPagerAdapter to FragmentStatePagerAdapter. The reason for that is that FragmentPagerAdapter does not recreate your Fragments if needed. It keeps everything in memory. So if your Fragment is not fully operational when it is created, or if you...
You need a FrameLayout. In a FrameLayout, the children are overlapped on top of each other with the last child being at the topmost. activity_main.xml <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"...
java,android,android-fragments,global
You could just pass the fragment manager into the method: public static void generateFragment(FragmentManager fragmentManager, String speechString, String buttonString) I would avoid having a BaseActivity as others have suggested, because it limits you to what you can extend from: e.g. FragmentActivity, ActionBarActivity, ListActivity, PreferenceActivity, e.t.c. Google "composition over inheritance" to...
java,android,multithreading,android-fragments,android-intent
You can do something like this. String str_Data = ""; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.MainActivity); String str_Name = ""; str_Name = setDataToText(str_Url); } private String setDataToText(String urlStr) { new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub //A code to retrieve data is executed...
You have so many questions, and I am trying to give a good summary for you. I have only two recommendations for you to read up on. Recommendation 1: Read webpage at Fragments Lifecycle. Code snippet to look at and understand: FragmentManager fragmentManager = getFragmentManager() FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Recommendation...
android,android-fragments,fragment,android-memory
You can use the setOffscreenPageLimit (int limit) method of the ViewPager to increase the number of fragments kept in memory. The default is 1 meaning there are 3 fragments in memory. (1 left and 1 right of the active one). You can try with 2 or 3. But don't go...
java,android,listview,android-fragments,expandablelistview
You shouldn't pass your view item form a fragment to an other. You should retrieve the object associated with your group view, pass this object to your second/edition fragment. You can use setTargetFragment(...) and onActivityResult(...) to send the modified text from your second to your first fragment. And then you...
java,android,android-fragments,media-player,android-mediaplayer
See, Singleton is a design pattern, and it is implemented by setting the default constructor as private, then you should provide a get method from wich you can recover your object instance. Check out the example bellow: public class Foo { private MediaPlaye md; private Foo () { md =...
java,android,google-maps,android-fragments,tabs
The FragmentPagerAdapter will always load both of your fragments simultaneously (since the user could swype to the next tab in any moment), and you cannot make the number of preloaded Fragments less then 2 (one for each side). If you want you can just initialize the map after the user...
android,android-fragments,android-asynctask
getFragmentManager() is a method of Activity, not Context. Since you're probably passing in an Activity as the context parameter anyway, you could hack this with: FragmentManager man = ((Activity) c).getFragmentManager(); but long term, best practice would be to pass either the Activity or the FragmentManager directly as an argument to...
android,android-fragments,imagebutton
In your onClick you are just missing to start the activity by the Intent Intent mainIntent = new Intent(getActivity(), abcd.class); startActivity(mainIntent); // <-- this is missing ...
java,android,android-fragments,dialogfragment,simpledialog
Suppose you have this code where you're creating your dialog FragmentManager fm = getActivity() .getSupportFragmentManager(); PedirTaxiDialog dialog = PedirTaxiDialog(); dialog.setTargetFragment(MainFragment.this, "some request tag"); dialog.show(fm, "Salvar Favoritos"); By calling method setTargetFragment() you're enabling option to get result from your DialogFragment as you're getting result from activity when you're starting it using...
android,android-fragments,android-asynctask
We cannot Cast Context object to Interface object. do the following : change constructor in AsyncRequest class public AsyncRequest(Context a, JSONObject p,OnAsyncRequestComplete caller) { this.caller = caller; context = a; parameters = p; } Replace following code in Your activity where you are calling AsyncRequest AsyncRequest getPosts = new AsyncRequest((Activity)getActivity(),obj,this);...
java,android,android-fragments,android-listview,swiperefreshlayout
Your recent_list is null and you are referencing it outside the onCreateView inside your RecentsCardFragment, this is why the NullPointerException happenning. Move your recent_list declaration into your onCreateView method, like this: public class RecentsCardFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { ListView recentsList; private SwipeRefreshLayout refreshBooks; ArrayList<HashMap<String,String>> items = new ArrayList<>(); //private...
android,android-fragments,android-view
Ok, fragment has method getView() : Get the root view for the fragment's layout (the one returned by {@link #onCreateView}), if provided. @return The fragment's root view, or null if it has no layout. You can do this like: try { ViewGroup rootView = (ViewGroup) getView(); int childViewCount = rootView.getChildCount();...
Create a container in the layout xml of FragmentA and load the common_fragment into that FragmentA. In fragment_a.xml <FrameLayout android:id="@+id/container" android:layout_width="wrap_content" android:layout_height="wrap_content"></FrameLayout> <GridView android:id="@+id/gridView1" android:layout_width="match_parent" android:layout_height="match_parent" ......... /> In the FragmentA.java @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout...
Set your root layout to clickable true so it will no more click on background fragment. eg. <LinearLayout android:clickable="true" > ......... Your Other Layout ......... </LinearLayout> ...
java,android,android-fragments,android-fragmentactivity,google-maps-api-2
The main issue is your android:minSdkVersion="16" What original docs said is If your android:minSdkVersion > 12 then you should use MapFragment with extends Activity And If yourandroid:minSdkVersion < 12 then you should use SupportMapFragment with extends FragmentActivity...
android,android-fragments,layout-inflater
In my opinion you should not apply animations in onCreateView if you want to see your animation on each page change. You should instead use OnPageChangeListener interface and apply your animation there once user has changed a pager (switching to another page). A simple code snippet to get you started....
android,android-fragments,memory,android-activity,picasso
Picasso has evictAll() API to clear cache. Also you can set Picasso disk cache size to something small or zero.
android,android-fragments,import
You are using FragmentActivity and getSupportFragmentManager(). Therefore, PlaceholderFragment needs to inherit from android.support.v4.app.Fragment, not android.app.Fragment.
android,android-fragments,android-toolbar,android-coordinatorlayout
I'd strongly recommend against changing the scrolling flags based on what tab is selected - having the Toolbar automatically return (and the content move down) when scrolling to a non-recyclerview tab can be very jarring and probably not an interaction pattern you want (exasperated if your two RecyclerView tabs are...
java,android,android-layout,android-fragments
Calling getActivity() is fine, it will resolve to a Context. You don't need the full getActivity().getApplicationContext(). This may cause a problem since you're telling Android to use the context of the application instead of the current Activity. Someday you'll appreciate this. Besides that, you NEED to create instance of dailyQuranMethods....
android,android-intent,android-fragments
This is a correct approach Send (in the Activity): final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); final DetailActivityFragment frg = new DetailActivityFragment (); ft.replace(R.id.container, frg); final Bundle bdl = new Bundle(); bdl.putString("yourKey", "Some Value"); frg.setArguments(bdl); ft.commit(); Receive (in the Fragment): final Bundle bdl = getArguments(); String str = ""; try { str...
android,android-fragments,android-fragmentmanager
You need to import your fragment as: import android.support.v4.app.Fragment; ...
android,android-fragments,android-viewpager,android-view
Let's break it down into steps: 1. Getting the references How this is done depends on what you already have. If the fields are created in-code, it's easy: Just store the references in a List<CommonBaseType>. If they are loaded from an XML Layout, there are multiple options. If you just...
android,android-intent,android-fragments,android-activity
It seems quite unusual for Android to clean up an activity in the way you described, but if that was the case I would think that your activity should still be restored. The fact that you don't return to the original activity and you can see from your debugging that...
android,android-layout,android-fragments,android-activity
Yes,I am able to get it to center,by programmatically doing it out,instead of xml layout.
android,android-fragments,android-mediaplayer
you can set volume for every mediaplayer. api
java,android,android-fragments
Found that, you logcat says everything Caused by: java.lang.ClassNotFoundException: com.paad.todoList.ToDoListFragment Your package name is not correct. use com.paad.todolist instead of com.paad.todoList This post reminds me the TV Show dialog, Sherlock : You see but you do not observe :) :)...
android,android-fragments,fragment,options-menu
Suppose you have 3 fragments (1) Fragment A (2) Fragment B (3) Fragment C You are going A to B then B to C then Backpress will return to B then again Backpress will return to A then Backpress will close app. Method for replace Fragment by adding Tag: Pass...
java,android,android-fragments,android-activity,android-fragmentmanager
A good solution could be use the SAME OnFragmentInteractionListener for all fragments, and use one param of each listener methods (like a TAG parameter) to identificate what fragment sent the action. Here an example: Make a new class and every fragment use this class OnFragmentInteractionListener.java public interface OnFragmentInteractionListener { public...
android,android-fragments,robolectric
When you call activity.recreate() you actually destroy your current activity and the reference you keep becomes invalid. You then try to use the FragmentManager of a destroyed activity and it crashes.
android,android-layout,android-fragments
I tried all the research and finally concluded that it is better to create your custom action bar. Following are the two very easy steps (got from different threads in different shapes, and compiling here). I hope this will be helpful for anyone (you just need to copy and past...
java,android,xml,android-layout,android-fragments
Try this I guess it will work for you <RelativeLayout 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="${packageName}.${activityClass}" android:id="@+id/semester"> <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/fragmentLayout" android:layout_centerVertical="true"...
android,android-fragments,recyclerview,android-actionmode
The problem seem to be from your onItemLongClicked method of the FragmentToday.java class. It should have been: @Override public boolean onItemLongClicked(int position) { if (actionMode == null) { actionMode = ((AppCompatActivity) getActivity()).startSupportActionMode(actionModeCallback); } toggleSelection(position); return true; } instead of: @Override public boolean onItemLongClicked(int position) { if (actionMode != null) {...
android,android-fragments,checkbox,android-studio
You need to assign an onclick listener to your delete button outside of the onChecked statement. Add it in code just after you assign the onClick event to the add button. This is because a view in android can only have 1 listener per event type. The onClick event can...
java,android,xml,android-layout,android-fragments
My guess is you need to init boolean before fragment transaction: if (findViewById(R.id.detail_container) != null) { mTwoPane = true; } FragmentWCLine newFragment = new FragmentWCLine(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.master_container, newFragment); transaction.commit(); Update: Also update click listener: listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long...
java,android,android-fragments,android-menu
The signature of your onCreateOptionsMenu doesn't look right. Take a look at the docs here Take a look this code @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);//Make sure you have this line of code. } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Add your menu entries...
android,android-fragments,fragmenttransaction,fragmentmanager
I fixed the issue by extending only activity instead of the support deprecated ActionBarActivity. Now the problem i have is that the action bar does not show
@Override public void onTabSelected(TabLayout.Tab tab) { Fragment f=heyWhatFragmentGoesInThisTab(tab); getFragmentManager() .beginTransaction().replace(R.id.where_the_tab_contents_go, f).commit(); } where you need to write: heyWhatFragmentGoesInThisTab() to return the Fragment that should be shown based upon the selected tab, and R.id.where_the_tab_contents_go, which is a FrameLayout that serves as the container for the active fragment IOW, you change fragments...
android,android-fragments,android-navigation,android-recyclerview
Why you call getActivity().getData(), just call getData(). And in your Adapter class: @Override public int getItemCount() { return 0; } It can't just return zero, you should return the data size....
android,exception,android-intent,android-fragments,textview
This occur when user clicks URL in text In this case, the URL is malformed: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) } The URL is href. That is not a valid URL. Here is the part where I do TextView html settings: That...
As @M D and @shkschneider mentioned above, you should use Interface here I have tried to provide sample here with code : public class MyFragment extends Fragment { private Activity activity; private ArrayList<DoSomethingInterface> callback = new ArrayList<DoSomethingInterface>(); private DoSomethingInterface callback1; public MyFragment(DoSomethingInterface interface) { this.callback1 = interface; } @Override public...
android,android-fragments,up-button
Answer is simple as I expected but I spend more than a day to get this clear. I implemented drawer step by step discovering documentation for every method. Ran app to notice any changes. I figured out that when setDisplayHomeAsUpEnabled(true) it's only changes drawer hamburger icon on back arrow icon...
java,android,android-fragments,gridview,baseadapter
You cant acces fragment views like that, becouse they could be not yet in the activity view hierarchy. You have to add some method to your fragment, like myCustomFragment.setGridAdapter(MyCustomGridViewAdapter adapter) and in this method in your custom fragment: public void setGridAdapter(){ this.myCustomGridAdapter = adapter; GridView gv = (GridView)findViewById(R.id.gridview); if(gv !=...
java,android,android-fragments,android-listview,android-listfragment
it is because R.string.america is an integer which represent a string inside strings.xml. So you should change the type for String[][] to int[][]. If you have to assign the value to a TextVIew android will take care of the look up in strings.xml.
com.example.shiza.dailyquranverses.SearchResultsActivity.onCreate(SearchResultsActivity.java this line shows there is some problem with your searchactivity values which cause null pointer exception, do check with your values
android,android-fragments,android-tabs
As @SubinSebastian answered here : Add the following project as a library project to your application. https://github.com/kolavar/android-support-v4-preferencefragment This solution is better than all other solutions. Add this project as a library project to your workspace. You can keep everything including your fragment transaction as it is and when importing the...
java,android,android-fragments,spannablestring
If LoginActivity is a fragment class then it would be okay is you use setOnClickListener on textview. But for fragment change you have to change Intent to fragmentTransaction, Use something like, textview.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentManager().beginTransaction().replace(R.id.container, new LoginActivity() ).addToBackStack("").commit(); }); But, if you want to...
android,android-fragments,interface,callback,android-dialogfragment
you have to call setTargetFragment setTargetFragment(this, 0); in order to get a reference FragmentXYXY, in your DialogFragment. @Override public void onClick(View v) { switch (v.getId()) { case R.id.et_i: DialogFragment newFragment = FragmentAlertDialog.newInstance(MainActivity.DIALOG_I, R.string.i_select, R.array.i_array); newFragment.setTargetFragment(this, 0); newFragment.show(getFragmentManager(), "dialog"); } } ...
java,android,android-fragments,noclassdeffounderror
First of all thanks a lot to everyone who helped me out with this. I've managed to get this error sorted. The problem was with using SherlockFragment. I simply changed my fragments to extend android.support.v4.app.Fragment and made the following change to displayView in my main activity if (fragment != null)...
Just taking a shot here, why have you placed the call to super and setContentView after Fragment transaction commit. In onCreate method, first call super then setContentView and then fragment transaction. @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fm = getFragmentManager(); //do some initialization stuff... FragmentManager fragmentManager = getFragmentManager();...
android,android-layout,android-fragments,android-viewpager
If you want your fragments to maintain its state even after changing the tabs, Try this, mViewPager.setOffscreenPageLimit(5); //as you have 5 fragments But this will make the activity to initialize all the fragments at the same time when the activity is invoked. Another method is to use FragmentStatePagerAdapter instead...
android,google-maps,android-fragments
You should use a FragmentActivity (or AppCompatActivity), and keep using your Fragment: <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MapsActivity" /> I don't see the usage of MapView anymore, nor in the official guides as of now. You should use SupportMapFragment....
android,android-fragments,navigation-drawer,androiddesignsupport
Write some code like this: navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); mDrawerLayout.closeDrawers(); switch (menuItem.getItemId()) { case R.id.your_menu_id: getSupportFragmentManager().beginTransaction().replace(R.id.fragment, getFragment(), "SET_A_TAG").addToBackStack("SET_A_TAG").commit(); break; } return true; } }); private YourFragment getFragment() { YourFragment f =...
android,google-maps,android-fragments,supportmapfragment
Based on post How to put Google Maps V2 on a Fragment Using ViewPager (see Brandon Yang's answer), I changed the MapaFragment.java code using MapView, and it worked. Like this: public class MapaFragment extends Fragment { Context mContext; private GoogleMap mMap; MapView mMapView; private Location location; private final static String...
android,android-layout,android-intent,android-fragments,android-activity
I fixed it by the following: Moving the followings to the fragment : private ListView mListView; private ListViewNewsAdapter listViewNewsAdapter; private ArrayList<ListViewNewsItem> listViewNewsItems; private JSONParser jsonParser = new JSONParser(); private String READNEWS_URL = "xxxxxxxx.xxxxx.xxxxx"; public CreateFragment() { // Required empty public constructor } Then, inside the onCreateView I created : mListView...
android,android-fragments,textview,onclicklistener
Don't even try to do this via onTouch. Use Spannables, and put each link inside a clickable span- http://developer.android.com/reference/android/text/style/ClickableSpan.html. Then when the text is clicked, its onClick method will be called and it can perform whatever action it needs to.
java,android-fragments,onclicklistener
Something like... public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.blackwidow_fragment, container, false); Button b = (Button)view.findViewById(R.id.your_button_id); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something when clicked... } }); return view; } ...
This is the solution: DownloadManager.Request request = new DownloadManager.Request(Uri.parse(files_url[position])); request.setTitle("File Downloading"); request.setDescription("File is being Downloaded..."); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE); String File_name = URLUtil.guessFileName(files_url[position],null,...
From my perspective, bind is more often used for 'joining' two separate entities (or instance) in which the two shares or manipulates a common data set. A service has onBind() because it will - or is - manipulate a particular set of data which will going to be passed back...
move handleIntent(intent); into onResume() you try to set the data in onCreate, but at this time the fragment isn't created you find more about this in the Fragments documentation: http://developer.android.com/guide/components/fragments.html#Lifecycle...
android,android-fragments,android-listview
The error message says: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead The OnClickListener is meant for click events on whole views. In an AdapterView, you usually want to register click events for each item separately. For this you need to use OnItemClickListener....
android,android-layout,listview,android-fragments,android-listfragment
Your scroll view is empty. If you want to have multiple items scrollable in it put a viewgroup layout inside in example a linear layout and then put button inside. Your views are returning null mostlikly because you didn't setcontentview() in the on create method. Rather than extending listActivity extend...
android,android-fragments,android-asynctask
If you use .get() for an AsyncTask than it is going to WAIT there until the result not arriving, which case the UI thread to be blokced, while task is running. USE .execute and use handlers to communicate with the task. In this case, you don`t need a handler, because...
Can I use one single DialogFragment subclass to display multiple and different (but simple and similar) yes you can. In your subclass of DialogFragment, you could define the keys of the information you want to display, and using a simple factory method, to instantiate the DialogFragment, filling up the...
java,android,android-fragments
Create an interface like- CustomDialogInterface.java public interface CustomDialogInterface { // This is just a regular method so it can return something or // take arguments if you like. public void okButtonClicked(String value); } and modify your MyAlert.java by- public class MyAlert extends DialogFragment implements OnClickListener { private EditText getEditText; MainActivity...
You just need an activity context passed in your constructor. Be sure to call new Adapter(this,...) from activities and new Adapter(getActivity(),...) from fragments. private Context context; @Override public void onClick(View v) { FragmentManager manager = ((Activity) context).getFragmentManager(); } ...
You can access the Activity instance from it's fragments by calling getActivity() So to show/hide progressbar in the Activity's Actionbar, you can use code like this: getActivity().setProgressBarIndeterminateVisibility(/*true or false here*/); ...
java,android,android-fragments,android-viewpager
this is a long solution so ask me if you dont understand something.. on the DadosPassageirosFragment add a boolean that decides if the object should be visible.. boolean isVisible; on the main Activity create all the Fragments and update the isVisible var according to your needs.. send all the fragments...
android,android-fragments,dagger-2
Your understanding is correct. The named scopes allow you to communicate intention, but they all work the same way. For scoped provider methods, each Component instance will create 1 instance of the provided object. For unscoped provider methods, each Component instance will create a new instance of the provided object...
android,android-fragments,android-activity,android-fragmentactivity
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.profile, container, false); Button newPage = (Button) v.findViewById(R.id.button2); newPage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), parseactivity.class); startActivity(intent); } }); Button newPage1 = (Button) v.findViewById(R.id.button1); newPage1.setOnClickListener(new View.OnClickListener() { @Override public...
android,android-fragments,android-activity,android-tabs
TabLayout can help. Before using TabLayout, you need to add compile 'com.android.support:design:22.2.0' to your build.gradle. You can read this page for further information....
java,android,android-fragments,android-activity
If you want to use Activity functions in fragment just use getActivity() for example getActivity().startActivity(yourIntent)
You're using a wrong layout for your list items. Change mForecastAdapter = new ArrayAdapter<String>(getActivity(), R.layout.fragment_main, ... to mForecastAdapter = new ArrayAdapter<String>(getActivity(), R.layout.list_item_forecast, ... The NPE comes when ArrayAdapter calls findViewById() to get the specified TextView from the list item layout but the view is not there and a null is...
android,android-fragments,android-activity
Change private static Integer[] icons = null; to private static int[] icons = null;? As an aside, that field does not need to be static particularly if you are always setting it in onCreate....
java,android,android-fragments,android-studio
here is a bug in your Code. cuz you have forgotten the reference to TextView so add TextView text = (TextView) rootView.findViewById(R.id.txtSource); and then text.setText("your text!"); hope work for you:)...
android,listview,android-fragments,android-viewpager
Because B, C is hosted in the ViewPager, so they are in the fragment A, so you just need to find fragment A and hide it. The real question is, where is the id home_frame_content. If this id is in Fragment A, D will be hidden once A is hidden....
android,android-fragments,asynchronous
getActivity() returning null is a perfectly valid scenario which you should expect as well. This happens because by creating anonymous Handler in your onCreateView you're referencing Fragment which was already detached from Activity (therefore getActivity() returns null). Same goes for your AsyncTask - if you're creating it as an anonymous...
android,android-fragments,android-activity
What you should do is to pass back the button event of your dialog fragment to the host activity, check the Passing Events Back to the Dialog's Host chapter in the Android dialog documentation. This is not only a good practice, but saves you alot of trouble, when you want...
android,android-layout,android-fragments,robolectric
Preference fragments are very different from regular fragment. Their layout is defined by the system and the content is inflated from XML resources. The purpose of this is to provide consistent settings screens in your apps. Have a look at the API Guide for more info.
android,google-maps,android-layout,android-fragments,layout
So this is how I ended up fixing my little predicament: I set a theme for the dialog, specifically mapDialogFragment.setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Light_Panel); And added some top and bottom padding in the layout. The result: Big up to saurabh1489 for helping me find the answer!...