Hey guys,
I am currently developing a mechanism for my app to store its database into a pdf file.
However, I am a bit stuck with the progressbar.
The progressbar is inside of a dialog.
The dialog is created in the main activity and then the asynctask is called, which should update the dialog's progressbar.
the method to achieve this, looks like this:
Code:
protected void onProgressUpdate(Integer... progress){
ProgressBar progressBar = (ProgressBar)((Activity)mContext).progressDialog.findViewById(R.id.pdfProgressBar);
progressBar.setProgress(progress[0]);
}
progressDialog is handed over within the constructor in the main activity:
(progressDialog = dialog)
Code:
Dialog dialog = new Dialog (this);
dialog.setContentView(R.layout.pdfprogress_dialog);
dialog.setTitle("Creating shopping list...");
dialog.setCancelable(false);
dialog.show();
createPDFTask pdfTask = new createPDFTask(this, elements, dialog);
pdfTask.execute("blabla");
dialog.dismiss();
Now eclipse throws me a funny error:
"progressDialog cannot be resolved or is not a field"
I believe there is soemthing wrong with the syntax of
Code:
ProgressBar progressBar = (ProgressBar)((Activity)mContext).progressDialog.findViewById(R.id.pdfProgressBar);
any idea what?
Related
Hi, I'm trying to create an application, and i require to use a variable input for a reference ID to display different arrays here is what i am using at the moment
Code:
public void verbTenses() {
Spinner verbs = (Spinner) findViewById(R.id.verbs);
Spinner tenses = (Spinner) findViewById(R.id.verb_tenses);
[COLOR="RoyalBlue"]ListAdapter adapter = R.array.(verbs.getSelectedItem() + "_" + tenses.getSelectedItem());[/COLOR]
ListView list = (ListView) findViewById(R.id.ListView01);
list.setAdapter(adapter);
}
the error area is highlighted
Thank you
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A
I have been working on a Home Screen widget for the past two days. The widget's `onUpdate()` method calls a service which fetches RSS information (title and image link) using `XmlPullParser`. These are working properly by printing the value in `LogCat`.
I want to set the text in the `TextView (tv1)` of AppWidget and image link as image to the `ImageView (imv1)` and a `TextView (go11)` clickable to open the browser and goto the link. I put the following in `OnStart()` just to test the SetText.
Code:
RemoteViews rv = new RemoteViews(this.getApplicationContext().getPackageName(),R.layout.main);
// Set the text
rv.setTextViewText(R.id.tv1,"WORKED");
Its not working. Second, I tried to set the image by:
Code:
InputStream is = (InputStream) new URL(imglnk).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
rv.setImageViewResource(R.id.imv1, 0);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
rv.setImageViewBitmap(R.id.imv1,bitmap);
Where imglnk is the link to the image. ImageView is not showing the image.
Then I tried to set the OnClick listener to open the browser with google as a test.
Code:
RemoteViews rv1 = new RemoteViews("com.example.axstartup",R.layout.main);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
PendingIntent pi = PendingIntent.getActivity(context, 0, browserIntent,PendingIntent.FLAG_UPDATE_CURRENT);
rv1.setOnClickPendingIntent(R.id.go11, pi);
Even that is not working. Please help me with this.
Hi!
I am trying to develop an android app with a google map v2, location service and some control buttons.
But I don't want to put all these things inside one MainActivity class. So I thought I could split all the code into some more classes. The MainActivity shall controll all the GUI things and react on map or location events...
Now I have the following problem. Inside my onCreate I instanziate the additional classes:
Code:
// Preferences as singleton
pref = Prefs.getInstance(this.getApplicationContext());
pref.loadSettings();
// Set up the location
loc = new Locations(pref);
loc.setCallback(this);
map = new MyMap(pref);
It seems to work fine. But inside the MyMap class every time I start the app a null pointer exception is thrown. When I am calling MyMap() the following code will be executed:
Code:
[...]
private Prefs pref;
private GoogleMap mMap;
[...]
public MyMap(Prefs prefs) {
pref = (Prefs) prefs;
if (mMap == null) {
FragmentManager fmanager = getSupportFragmentManager();
mMap = ((SupportMapFragment) fmanager.findFragmentById(R.id.map)).getMap();
[...]
}
The line with the findFragmentById is the one that causes the exception.
If I write
Code:
SupportMapFragment f = ((SupportMapFragment) fmanager.findFragmentById(R.id.map));
f is allways null. But how can I access the fragments and view elements defined within my MainActivity?
It works if I put the code inside my MainAcitivity.
Every class extends "android.support.v4.app.FragmentActivity"
I tried to save the application context within my Prefs() class, so that I can access it from everywhere.
But I don't know how to use it inside my additional classes.
How to share the "R" across all my classes?
Can someone help me please?
Thank you very much!!
Thorsten
Are you having trouble adding a Map to a Fragment? If so, then you may take a look at this tutorial. I haven't tried it myself since I couldn't install Google Play Services on my development device. If it helps, do write back, as I am definitely going to try it myself soon.
on 4.4 and earlier android. I use
Code:
findAndHookMethod("com.android.systemui.statusbar.policy.DateView", lpparam.classLoader, "updateClock" new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param){
mDateView = (TextView) param.thisObject;
mDateView.setText("Hello");
}
});
to change the date text(e.g "December 1" to "Hello").
The class name and function name should be hooked are not changed, but this method not works on LP.
I'm trying to find another way to make it but failed. I'm not good at programming, so I need your help!
In the below code, where the item’s position and title is getting saved in list_items works fine if list_items and items are ArrayList. For ex;
Code:
ArrayList.add(ArrayList.get(position));
But I am trying to use listview:
Code:
ArrayList.add(Listview.get(position));
The problem exists on line # 10
Code:
1. final Listadapter Adapter = new Listadapter(this,packageList1, packageManager);
2. items.setAdapter(Adapter);
3. items.setChoiceMode(apps.CHOICE_MODE_MULTIPLE_MODAL);
4. items.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
5. @Override
6. public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
7. count = count +1;
8. mode.setTitle(count + "items selected");
9. //problem resides in the below line
10. [B]list_items.add(items.get(position));[/B]
11. }
In the above code, on selecting an item from listview I am trying to save it in an Arraylist i.e list_items which could be used in onActionItemClicked method for further action on that respective item.
Any ideas on how to solve or find a workaround to use a listview in the above situation?