Can't use getFragmentManager() [duplicate] - java

This question already has answers here:
Since the Android getFragmentManager() API is deprecated, is there any alternative?
(14 answers)
Closed 1 year ago.
I have a fragment and I want to add its data to another fragment via getFragmentManager() but this metod has been deprecated and now I don't know what to do.
Screenshot

You can use FragmentActivity.getSupportFragmentManager().
Visit Since the Android getFragmentManager() API is deprecated, is there any alternative?
for more details .

Related

Issues with getDrawable compatibilty [duplicate]

This question already has answers here:
Android getResources().getDrawable() deprecated API 22
(16 answers)
Closed 4 years ago.
This is the line in question. I have it the same way the textbook lists it, but am having issues converting the line to ContextCombat since getDrawable() has been deprecated.
buttonItem.setImageDrawable(getResources().getDrawable(painting.getId()));
You can try using ContextCompat.getDrawable(getActivity(), R.drawable.name);. This will return a styled Drawable as instructed by your Activity's theme. Your code would be more or less as shown below:
buttonItem.setImageDrawable(ContextCompat.getDrawable(getActivity(), painting.getId()));
NOTE: I'm assuming that painting.getId() returns the resource id for the image you want to set as your button's drawable. Also, if you are doing this inside an Activity, you should use the keyword this instead of getActvity().

Is there any lifecycle method which will get called each time when a fragment is opened? [duplicate]

This question already has answers here:
ViewPager with fragments - onPause(), onResume()?
(10 answers)
Closed 4 years ago.
I tried to use onStart() but it doesn't invoke with ViewPager in some cases, especially when going to fragment from nearest tab on tablayout.
What can be problem?
Is there any other events that invoke explicitly?
Fragment#onResume() will be called when the fragment is visible to the user and actively running. This is generally tied to Activity.onResume of the containing Activity's lifecycle.

How to send an object from activity to fragment? [duplicate]

This question already has answers here:
Passing an Object from an Activity to a Fragment
(8 answers)
Closed 7 years ago.
I just want to use getActivity().data in my fragment to pull in the data object.
It's not working though. Eclipse says that data cannot be resolved.
It looks like there is plenty of information about how to use Bundle to do this.
However, I am wondering how to use getActivity in particular.
Although using Bundle is the preferred way and following way must be avoided but just to answer your question, try making the data variable static and access it by typecasting the activity ((YourActivity)getActivity()).data.

Android - Disable softkeybaord from poping up [duplicate]

This question already has answers here:
How to close/hide the Android soft keyboard programmatically?
(126 answers)
Closed 8 years ago.
I am programming for a Pidion device that is running Android 2.3.7 (Gingerbread). The Pidion comes with a built in keyboard and I would like to disable the softkeyboard from opening.
What is the best way to disable softkeyboard?
try this:
((EditText) findViewById(R.id.editTextReference)).setInputType(InputType.TYPE_NULL);
inside Activity you can do this:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
or inside Fragment you can just use
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

How to make a rolling news banner on android? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
marquee text in android
in my app i want to have a news banner with the words moving to one side like tv .. i don't really know how to run that kind of animation .. and should the banner be a TextView ? i'm not really sure of anything .. so i just need the xml format of such thing, Thankss!
This is commonly referred to as a ticker or marquee. Here's a tutorial on how to make one.
Edit: Here's another tutorial.
Edit: Here's another stackoverflow question about the same thing.
Edit: And another.

Categories

Resources