These code examples were ranked by Codota’s semantic indexing as the best open source examples for Activity setProgressBarVisibility method.
progressDialog.dismiss(); } progressDialog = null; } else { Activity parent = (Activity) proxy.getActivity(); parent.setProgressBarIndeterminate(false); parent.setProgressBarIndeterminateVisibility(false); parent.setProgressBarVisibility(false); parent.setTitle(statusBarTitle); statusBarTitle = null; } visible = false; } @Override public void onCancel(DialogInterface dialog) { visible = false; fireEvent(TiC.EVENT_CANCEL, null); } }
12: super.onCreate(savedInstanceState);
13: requestWindowFeature(Window.FEATURE_PROGRESS);
14: setProgressBarVisibility(true);
15: getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
16: setContentView(R.layout.demo_view);
Hello guys After much consideration and looking at hell lot of options and workarounds I think OliveDocLibrary is the best way to do it. Here is the link which will give direct you to the downloads page of three libraries for Android which are for DOC, XLS and PPT. All these work excellently well. The package folder you will download will have three folders inside. which are:
In the demo folder you will find a sample project for Word. You can directly import this project into your workspace in Eclipse and test the code yourself. For peoples convenience am posting that code here. I have deleted some part of the code which I felt was not necessary(w.r.t the answer to my question here). So the code has two files, The main activity is FileChooser
which is as follows:
public class FileChooser extends Activity {
private String filePath = Environment.getExternalStorageDirectory()
.getPath() + "/simple.docx";
MyBaseAdapter adapter;
private static String parentPath;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(2);
copyFileToSdcard();
Intent intent = new Intent(FileChooser.this,
OliveWordTrailDemoAcitivy.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.fromFile(new File(filePath)));
startActivity(intent);
}
class MyBaseAdapter extends BaseAdapter {
private String[] list;
public MyBaseAdapter(String[] list) {
this.list = list;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = new TextView(FileChooser.this);
((TextView) convertView).setTextSize(35);
}
((TextView) convertView).setText(list[position]);
return convertView;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public int getCount() {
return list.length;
}
public void setList(String[] list) {
this.list = list;
}
};
class MyItemClickListener implements OnItemClickListener {
String[] list;
InputStream is;
public MyItemClickListener(String[] list) {
this.list = list;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
File file = new File(parentPath + list[position]);
if (file.isFile()) {
Intent intent = new Intent(FileChooser.this,
OliveWordTrailDemoAcitivy.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.fromFile(file));
startActivity(intent);
} else {
list = file.list();
adapter.setList(list);
adapter.notifyDataSetChanged();
parentPath = file.getAbsolutePath() + "/";
}
}
}
private void copyFileToSdcard() {
InputStream inputstream = getResources().openRawResource(
R.raw.simple);
byte[] buffer = new byte[1024];
int count = 0;
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File(filePath));
while ((count = inputstream.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
fos.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
Toast.makeText(FileChooser.this, "Check your sdcard", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Here I have placed a doc file named simple.docx which includes images and mathematical symbols which are rendered and displayed properly. This activity interacts with OliveWordTrialDemoActivity
which is as follows:
public class OliveWordTrailDemoAcitivy extends Activity implements
OnClickListener, CommentListener, NoteListener, HyperlinkListener, ProgressListener {
OliveWordOperator viu;
EditText searchEditText;
ArrayList<String> bookmarks;
Handler handler;
protected void onCreate(Bundle savedInstanceState) {
viu = new OliveWordOperator(this, this);
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_PROGRESS);
setProgressBarVisibility(true);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
setContentView(R.layout.demo_view);
OliveWordView view = (OliveWordView) findViewById(R.id.test_view);
try {
viu.init(view, getIntent().getData());
viu.start(viu.isEncrypted(), "111");
} catch (Exception e) {
e.printStackTrace();
}
handler = new Handler(){
@Override
public void handleMessage(Message msg) {
setProgress(msg.what * 10);
super.handleMessage(msg);
}
};
}
@Override
protected void onDestroy() {
viu.release();
super.onDestroy();
}
@Override
public void getComment(ArrayList<String[]> comments) {
for (int i = 0; i < comments.size(); i++) {
AlertDialog.Builder builder = new Builder(this);
builder.setTitle(comments.get(i)[0]).setMessage(comments.get(i)[1])
.show();
}
}
@Override
public void getHyperlink(String hyperlink) {
if (Uri.parse(hyperlink).getScheme().contains("mailto")) {
try {
startActivity(new Intent(Intent.ACTION_SENDTO,
Uri.parse(hyperlink)));
} catch (ActivityNotFoundException anfe) {
Toast.makeText(this, "can't found email application",
Toast.LENGTH_SHORT).show();
}
} else {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(hyperlink)));
}
}
@Override
public void getNote(SparseArray<String> notes) {
for (int i = 0; i < notes.size(); i++) {
AlertDialog.Builder builder = new Builder(this);
if (notes.keyAt(i) == NoteListener.FOOTNOTE) {
builder.setTitle("footnote").setMessage(notes.valueAt(i))
.show();
} else if (notes.keyAt(i) == NoteListener.ENDNOTE) {
builder.setTitle("endnote").setMessage(notes.valueAt(i)).show();
}
}
}
public void goToBookmarks(String name) {
viu.goToBookmark(name);
}
public void listBookmarks() {
this.bookmarks = viu.listBookmarks();
}
@Override
public void notifyProgress(int progress) {
handler.sendEmptyMessage(progress);
}
@Override
public void onClick(View v) {
}
}
In the lib_trial folder you will find the library which can be added to your libs folder if you want to use it separately.
And in the API folder you will find a detailed description of the library and its methods in form of a pdf file which is very easy to understand. so people can just use this library directly and use the methods provided to their specific requirement.
So that's the solution am going with for now. Any better solutions are welcome. The bounty time is about to get over soon so please provide any other solution you may have as soon as possible. Thanks.
13: }
14: });
15: setProgressBarVisibility(true);
16:
17: webview.getSettings().setJavaScriptEnabled(true);
Don't know what you are pretending exactly with onCreateOptionsMenu. That would be the code that should be in onCreate
That way, you should set the WebViewClient in the onCreate method.
Then, your code should be like:
private static WebView webView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
webview = new WebView(this);
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
return false;
}
});
setProgressBarVisibility(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
setContentView(webview);
final Activity activity = this;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
webview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
webview.loadUrl("http://www.example.com/droid/mobile_index.html");
return true;
}
Give it a try!
5: setContentView(R.layout.browser);
6: setProgressBarIndeterminateVisibility(true);
7: setProgressBarVisibility(true);
8: findViewById(R.id.enable).setOnClickListener(new View.OnClickListener() {
9: @Override
-
10: public void onClick(View arg0) {
11: setProgressBarIndeterminateVisibility(false);
12: setProgressBarVisibility(false);
13: }
14: });
Try out as below:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.browser); setProgressBarIndeterminateVisibility(true); setProgressBarVisibility(true); findViewById(R.id.enable).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { setProgressBarIndeterminateVisibility(false); setProgressBarVisibility(false); } }); }
1: getSherlock().setProgressBarVisibility(visible);
I am just enabling and disable the ActionBarShareLock ProgressBar.
Not sure but might be helpful to you. Below is my code:
public class IndeterminateProgress extends SherlockActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
super.onCreate(savedInstanceState);
//This has to be called before setContentView and you must use the
//class in com.actionbarsherlock.view and NOT android.view
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.iprogress);
findViewById(R.id.enable).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
setSupportProgressBarIndeterminateVisibility(true);
}
});
findViewById(R.id.disable).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
setSupportProgressBarIndeterminateVisibility(false);
}
});
}
}
Updated
have you try with this:
getSherlock().setProgressBarIndeterminate(indeterminate);
OR
getSherlock().setProgressBarVisibility(visible);
I mean try with call getSherlock() before going to Ideterminate or change its visibility.
Let me comment of result.
Hope this will help you.