jqueryandroid
A. android怎么实现 jquery 的效果
Android的ProgressDialog效果就是典型的android实现jquery效果的应用。
首先需要创建ProgressDialog对象,然后使用线程控制进度条显示,具体源代码:
package com.yarin.android.TestOnPDialog;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class PDialog extends Activity
{
private Button mButton01,mButton02;
int m_count = 0;
//声明进度条对话框
ProgressDialog m_pDialog;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//得到按钮对象
mButton01 = (Button)findViewById(R.id.Button01);
mButton02 = (Button)findViewById(R.id.Button02);
//设置mButton01的事件监听
mButton01.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
//创建ProgressDialog对象
m_pDialog = new ProgressDialog(PDialog.this);
// 设置进度条风格,风格为圆形,旋转的
m_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
// 设置ProgressDialog 标题
m_pDialog.setTitle("提示");
// 设置ProgressDialog 提示信息
m_pDialog.setMessage("这是一个圆形进度条对话框");
// 设置ProgressDialog 标题图标
m_pDialog.setIcon(R.drawable.img1);
// 设置ProgressDialog 的进度条是否不明确
m_pDialog.setIndeterminate(false);
// 设置ProgressDialog 是否可以按退回按键取消
m_pDialog.setCancelable(true);
// 设置ProgressDialog 的一个Button
m_pDialog.setButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int i)
{
//点击“确定按钮”取消对话框
dialog.cancel();
}
});
// 让ProgressDialog显示
m_pDialog.show();
}
});
//设置mButton02的事件监听
mButton02.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
m_count = 0;
// 创建ProgressDialog对象
m_pDialog = new ProgressDialog(PDialog.this);
// 设置进度条风格,风格为长形
m_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// 设置ProgressDialog 标题
m_pDialog.setTitle("提示");
// 设置ProgressDialog 提示信息
m_pDialog.setMessage("这是一个长形对话框进度条");
// 设置ProgressDialog 标题图标
m_pDialog.setIcon(R.drawable.img2);
// 设置ProgressDialog 进度条进度
m_pDialog.setProgress(100);
// 设置ProgressDialog 的进度条是否不明确
m_pDialog.setIndeterminate(false);
// 设置ProgressDialog 是否可以按退回按键取消
m_pDialog.setCancelable(true);
// 让ProgressDialog显示
m_pDialog.show();
new Thread()
{
public void run()
{
try
{
while (m_count <= 100)
{
// 由线程来控制进度。
m_pDialog.setProgress(m_count++);
Thread.sleep(100);
}
m_pDialog.cancel();
}
catch (InterruptedException e)
{
m_pDialog.cancel();
}
}
}.start();
}
});
}
}
B. 请教:在Android和jQuery mobile联合开发中如何设置返回键退出
如果页面中链接,
如果希望点击链接继续在当前
browser
中响应,
而不是新开
Android
的系统browser
中响应该链接,必须覆盖
webview
的
WebViewClient
对象。mWebView.setWebViewClient(new
WebViewClient(){
public
boolean
shouldOverrideUrlLoading(WebView
view,
String
url)
{
view.loadUrl(url);
return
true;
}
});
如果不做任何处理,浏览网页,点击系统“Back”键,整个
Browser
会调用
finish()而结束自身,
如果希望浏览的网页回退而不是推出浏览器,需要在当前
Activity
中处理并消费
掉该
Back
事件。public
boolean
onKeyDown(int
keyCode,
KeyEvent
event){
if
((keyCode
==
KeyEvent.KEYCODE_BACK)
&&
mWebView.canGoBack())
{
mWebView.goBack();
return
true;
}
return
super.onKeyDown(keyCode,
event);
}
不知道你是用什么控件来开发web
,如果你不重写onKeyDown
点击系统“Back”键就会退出的。
C. android上能运行jquery吗
可以。jquery有移动版的。
D. jquery mobile 能开发android手机界面吗
可以的
jquery mobile 1.2.0 对android 2.1~2.3 3.2 4.0 4.1等都是A级支持,就是完全支持。
E. android 怎么使用jquery
正常应用上是用不了jquery的
phonegap 这是个框架,了解一下,可以用html做android应用,就能用了