I have a SherlockFragmentActivity using tabhost and viewpager. Calling
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
in the fragmentactivity creates the spinner, and calling
setSupportProgressBarIndeterminateVisibility(false);
won't disable it. I also don't seem to be able to call getActivity().setSupportProgressBarIndeterminateVisibility(false);
from the fragments;
I get the error "The Method setSupportProgressBarIndeterminateVisibility(boolean) is undefined for the type FragmentActivity."
What am I doing wrong, can someone show me the way how to use it properly in fragments? I want to be able to create the progressbar in my asynctask pre execute and stop it in postexecute.
I'm using2.2 emulator and importing import com.actionbarsherlock.view.Window; instead of the android.view one.
[Edit] I just confirmed using setProgressBarIndeterminateVisibility works in the 4.1 emulator. Anyway, I need to get this work in 2.2
"I also don't seem to be able to call getActivity().setSupportProgressBarIndeterminateVisibility(false); from the fragments;"
You need to be calling getSherlockActivity() instead of getActivity().
"I'm using2.2 emulator and importing import com.actionbarsherlock.view.Window; instead of the android.view one."
Plus one for that, hadn't spotted that import and came across this post which fixed my bug - wasn't showing the progress indicator in Gingerbread before, many thanks :)
This works perfect for me:
getActivity().setProgressBarIndeterminate(true);
ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.show(getActivity(), "This is", " a message...");
May you help ;)
Related
I've tried searching for the Java tutorial regarding creating my LottieAlertDialog, but I can't find any. Everywhere it's in Kotlin, but I need the Java code as my project is in Java.
I've tried creating my LottieAlertDialog in this way:
LottieAlertDialog.Builder alert=new LottieAlertDialog.Builder(context,DialogTypes.TYPE_CUSTOM,
"social.json") //Here social.json is inside assets folder
.setTitle("Social")
.setDescription("social");
alert.build();
But the dialogbox doesn't show, when I run the app. To check whether my alert dialogbox was being created or not I tried testing it by printing the description set in the dialog in a Toast:
Toast.makeText(context,alert.getDescription(),Toast.LENGTH_SHORT).show();
The toast works and its showing "social"! That means the dialog is being created. But unfortunately it doesn't show in my app. What do I do? I've implemented all the dependencies as shown in the below link:
lottiealertdialog
Ok, after much hankering, I finally came to the solution. It's
alert.build().show();
The thing is not related to Kotlin or Java as such, you need to show the dialog once you have built it. So far your code is correct. You just need to show it further like this
LottieAlertDialog.Builder alert = new LottieAlertDialog.Builder(context, DialogTypes.TYPE_CUSTOM,
"social.json")
.setTitle("Social")
.setDescription("Social")
.build()
.show();
I'm trying out a login tutorial (Create an Android login system using MySQL) on Android Studio 3.0. I ran into these errors:
import android.os.AsyncTask; (Click here to see the error)
When I hover on it, it says:
Unused import statement
onPreExecute() (Click here to see the error)
The message shows:
Error:(52, 14) error: cannot find symbol method onPreExecute()
Can anybody help me out? I'm new to this. I'm sorry if the question is not that clear.
Ok i understand your problem, when you create class extend Asyntask, you should Override three methods (onPreExecute, doInBackground and onPostExecute). In order to Override methods, any position mouse in class extend Asyntask you right click and choise Generate...(or shortKey: Alt + Insert) --> Override Methods --> choise onPreExecute, doInBackground and onPostExecute). See all step with images below:
finish Override for Asyntask.
I feeling your question unclearly, if you have error: cannot find symbol method onPreExecute() so right click Source in your Asyntask class -> Override --> Implement method and figure out onPreExecute() method.
Try Rebuild the project or restart android studio. Android Studio sometimes gives these kinds of issues
My IDE shows me the error even is empty project. As you can see I create the new project with empty activity. App is launched in mobile successfully and work fine. but logcat isn't working properly or any thing else I'm stuck help me out. And when I connect my mobile even I didn't build the project logcat is full of instruction/logs.
UPDATE:
First, gralloc stands for the low-level graphics buffer allocator.
The gralloc is part of the HAL (Hardware Abstraction Layer) which
means that the implementation is platform-specific. You can find the
interface definitions in
hardware/libhardware/include/hardware/gralloc.h. As expected from a
HAL component, the interface is divided into a module interface
(gralloc_module_t) and a device interface (alloc_device_t).
The error is very low level and related with OpenGLRenderer. Your device is trying to open some 64-bit library files, but if fails. Then the error occurs.
I did very deep search about this but nothing useful came up.
Try running apps on another devices and see the error occurs again.
Continue developing if the error is not causing crash or other important issue. If you find a solution, you will try again.
in my case, I tried to use Application class static context for calling new Activity and I changed it to local static Activity and problem solved.
Notice that this problem doesn't happen in all devices it just occur in some cases.
private static MainActivity u_static;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_users);
u_static = this;
}
public static void new(int id, String name){
Intent i = new Intent(u_static, NewActivity.class);
u_static.startActivity(i);
}
And something I notice that in some devices when an application stops working instead of showing error, this error happens. Trace and debug your codes.
About the crazy E/HAL: load: id=gralloc != hmi->id=gralloc
Reason for error: Generally, it is caused by the fact that the control object is not fetched, the click event of the control is executed, and the null value is related to the initialization control.
As
private Button bt;
bt.setOnclickListener(new OnClickLisenter(){....});
Is there a problem? Yes!
xml layout control
Check if the findViewById() is missing in the java code!
The above leaked bt = (Button) findViewById(R.id...);
java dynamic new control / custom control error
Check if you forgot to create the object!
The above leaked bt = new Button();
So the correct way to change the above code is:
private Button bt;
bt=(Button)findViewById(R.id...);
I encountered this issue while using runnable and passing an unassigned view.
This is caused by an empty view object where findViewById returns a null value.
Instead of passing the view object passing the value the view holds resolved the issue.
I have 2 activities (ListActivity and ContactsActivity)
Both works perfectly without Admob.
But if I have admob in ListActivity, it works perfectly but when I click a button to change to ContactsActivity (it have an AsyncTask function to get all contacts from mobile) the application exploits with this error:
If anyone can help me how to solve this problem or telling other options do.
Thanks in advance.
Loading of Ads might be throwing any un-handled exception. Try surrounding the ads-loading code in try-catch. Or paste the code in here.
Edit: If you are loading ads in the AsyncTask, remove it from there. Call the loading of ad after loading the contacts list.
Like:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new LoadContactsList();
...
Method to load your ads;
}
I can confirm that adding the following code in my initial Activity solves the problem:
try {
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore) {}
I setup ActionBarSherlock with my app, and I'm trying to use the Intermediate Progress, I'm using this:
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setSupportProgressBarIndeterminateVisibility(false);
In my onCreate, and then using:
setSupportProgressBarIndeterminateVisibility(true);
To enable it.
It works fine in ICS but it doesn't work at all in Gingerbread or Froyo, does anyone know how to get it to work? Thanks
I just had the same problem. Jake's solution above did not fix it for me - the method is undefined.
I found a working solution posted by Jake on the bug list for ActionBarSherlock here:
Action Bar Indeterminate Progress Bar Not Disappearing
See Jake's response to the poster - the trick is to call getSupportActionBar() first, to "trigger creation of the views".
So my onCreate() method is:
protected void onCreate(Bundle arg0)
{
super.onCreate(arg0);
// allow window to show progress spinner in the action bar
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
getSupportActionBar();
setSupportProgressBarIndeterminateVisibility(false);
}
Update based on comment from Laux:
Make sure your imports reflect com.actionbarsherlock.view.Window.FEATURE_INDETERMINATE_PROGRESS for this to work.
Here is part of my import block from an app that uses this pattern:
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.ActionProvider;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import com.actionbarsherlock.widget.ShareActionProvider;
This is a very good thing to remember when working with ABS - many of your normal Android imports should be updated to refer to ABS instead.
It may be a good idea to revisit your import block, or possibly remove it entirely and let Eclipse rebuild it for you (CTRL-SHIFT-O) to which point Eclipse will prompt you for each import that ABS redeclares.
This was also explained by Glebbb in his answer.
I'm sure you've probably figured it out by now, but the most likely culprit is you including the wrong file because it's so easy to do automatically.
Replace any import of android.view.Window with com.actionbarsherlock.view.Window and the needed features will work.
You need to call supportRequestWindowFeature.
requestWindowFeature is a final method on Activity and couldn't be overriden.
Check, if you are using Theme.Sherlock.NoActionBar or similar no action bar theme for this activity.
In this case setSupportProgressBarIndeterminateVisibility method fails for me with
Caused by: java.lang.NullPointerException
at com.actionbarsherlock.internal.ActionBarSherlockCompat.updateProgressBars(ActionBarSherlockCompat.java:710)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.onIntChanged(ActionBarSherlockCompat.java:686)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.updateInt(ActionBarSherlockCompat.java:681)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setFeatureInt(ActionBarSherlockCompat.java:665)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setProgressBarIndeterminateVisibility(ActionBarSherlockCompat.java:637)
at com.actionbarsherlock.app.SherlockFragmentActivity.setSupportProgressBarIndeterminateVisibility(SherlockFragmentActivity.java:282)
I guess you should use a progress dialog instead to indicate loading process or regular Theme with activity title bar and then use setProgressBarIndeterminateVisibility method for older platforms.