我在android中开发一个应用程序,我需要在sqlite中创建一个udf.是否可以在sqlite中创建它?如果是的话怎么做?
我正在试图弄清楚如何利用移动视口元标记自动缩放HTML页面的内容以适应Web视图.
约束:
例如,如果我有一个图像(640x100px),我希望在webview为300x250(缩小到适合)时缩小图像.另一方面,如果webview是1280x200,我希望图像放大并填充webview(放大到适合).
在视口上阅读android文档和iOS文档之后,看起来很简单:因为我知道我的内容的宽度(640)我只是将视口宽度设置为640并让webview决定是否需要向上或向下缩放内容适合webview.
如果我将以下内容放入我的Android/iPhone浏览器或320x50 webview中,则图像不会缩小以适应宽度.我可以向右和向左滚动图像..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Viewport</title>
<meta name="viewport" content="width=640" />
<style type="text/css">
html, body {
margin: 0;
padding: 0;
vertical-align: top;
}
h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,cite,code,del,dfn,em,img,q,s,samp,small,strike,strong,sub,sup,tt,var,dd,dl,dt,li,ol,ul,fieldset,form,label,legend,button,table,caption,tbody,tfoot,thead,tr,th,td
{
margin: 0;
padding: 0;
border: 0;
font-weight: normal;
font-style: normal;
font-size: 100%;
line-height: 1;
font-family: inherit;
vertical-align: top;
}
</style>
</head>
<body>
<img src="http://www.dmacktyres.com/img/head_car_tyres.jpg">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?视口元标记是否仅放大<webview区域的内容?
我正在ApplicationInfo使用packageManager.getInstalledApplications(0)获取对象列表,并尝试根据它们是否是系统应用程序对它们进行分类.
有一段时间我一直在使用这里描述的技术,但是在我的应用程序中看到之后,一些应用程序不在非系统应用程序列表中(例如Facebook,当可用时要求系统在SD上安装自己)卡).在下次阅读ApplicationInfo.FLAG_SYSTEM的实际文档并了解它实际上没有过滤系统应用程序之后,我现在正在寻找一种新方法.
我的猜测是,系统和非系统应用程序的UID之间存在很大差距,我可以收集这些差异来进行区分,但到目前为止我还没有找到答案.我也查看了其他标志,例如ApplicationInfo.FLAG_EXTERNAL_STORAGE,我支持API 1.5.
有没有人有这个真正的解决方案(不涉及FLAG_SYSTEM)?
我正试图找出scanResult当前连接的wifi网络.
这是我的代码
public boolean IsCurrentConnectedWifi(ScanResult scanResult)
{
WifiManager mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo currentWifi = mainWifi.getConnectionInfo();
if(currentWifi != null)
{
if(currentWifi.getSSID() != null)
{
if(currentWifi.getSSID() == scanResult.SSID)
return true;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
我没有问题得到scanresult.
总是我得到currentWifi是null.
我错在哪里或有没有其他方法可以做到这一点?
我想知道服务和广播接收器之间的区别,任何人都可以指出一个可以在Android移动设备上观察到的例子.谢谢
我有一个课程View1延伸View.我想R.layout.test2.xml在这堂课中充气View1.我在这个类中添加了以下代码
public class View1 extends View {
View view;
String[] countries = new String[] {"India", "USA", "Canada"};
public View1( Context context) {
super(context);
LayoutInflater mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view=mInflater.inflate(R.layout.test2, null, false);
}
}
Run Code Online (Sandbox Code Playgroud)
从另一个类Home我希望这个膨胀的视图在某些情况下存在,在Home类中我编写了以下代码:
public class Home extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
CreateView();
}
public void CreateView() {
LinearLayout lv=(LinearLayout)findViewById(R.id.linearlayout);
View1 view = new View1(Home.this);
lv.addView(view);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行我的项目时,活动并没有向我显示任何内容.
可能重复:
如何在Java中将数字舍入到n个小数位
我很难将浮点数舍入到小数点后两位.我已经尝试了一些我在这里看到的方法,包括只是使用Math.round(),但无论我做什么,我都会得到不寻常的数字.
我有一个我正在处理的浮动列表,列表中的第一个显示为1.2975118E7.什么是E7?
当我使用Math.round(f)(f是浮动)时,我得到完全相同的数字.
我知道我做错了什么,我只是不确定是什么.
我只想要数字格式x.xx.第一个数字应该是1.30,等等.
我在6年前问过这个问题.与此同时,Android开发最佳实践已发生变化,我已成为更好的开发人员.
从那以后,我意识到使用onClickXML属性是一种不好的做法,并将其从我工作的任何代码库中删除.
我的所有点击处理程序现在都在应用程序的代码中定义,而不是XML布局!
我从不使用的理由onClick是
onClickXML属性的值中出错,这将导致运行时错误onClick它们混合起来,这很糟糕!我希望我已经说服你永远不要onClick在布局中使用:)!
下面是我原来的问题,这是一个很好的说明为什么使用onClick是一个坏主意.
===
我在XML中定义菜单项,并尝试使用API 11中添加的onClick属性.当在运行4.0.3的模拟器中启动Activity时,会发生以下异常:
FATAL EXCEPTION: main
android.view.InflateException: Couldn't resolve menu item onClick handler
onFeedbackMenu in class android.view.ContextThemeWrapper
...
Caused by: java.lang.NoSuchMethodException: onFeedbackMenu
[interface com.actionbarsherlock.view.MenuItem]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
Run Code Online (Sandbox Code Playgroud)
我不明白导致异常的原因,因为我的Activity中定义了以下方法
import com.actionbarsherlock.view.MenuItem;
...
public void onFeedbackMenu( MenuItem menuItem ) {
Toast.makeText( this, "onFeedBack", Toast.LENGTH_LONG ).show();
}
Run Code Online (Sandbox Code Playgroud)
我的XML菜单定义文件包含:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
...
<item
android:id="@+id/menu_feedback"
android:icon="@drawable/ic_action_share"
android:showAsAction="ifRoom"
android:title="@string/menu_feedback"
android:onClick="onFeedbackMenu" />
</menu>
Run Code Online (Sandbox Code Playgroud)
为了向后兼容,我使用的是ActionBarSherlock,当我在2.3.x上运行App时,它也会得到一个非常类似的Exception.
这是堆栈跟踪的更完整版本 …
我正在尝试使用我创建的函数直接将位图保存到文件和特定文件.它不起作用.它在bitmap.compress部分之后崩溃(在here3之前).
File dir = new File(filepath);
if(!dir.exists())dir.mkdirs();
File file = new File(Environment.getExternalStorageDirectory() + filepath, side + ".png");
FileOutputStream fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
System.out.println(filepath);
bitmap.recycle();
System.gc();
Run Code Online (Sandbox Code Playgroud)
错误日志:
06-29 00:16:38.089: D/AndroidRuntime(3260): Shutting down VM
06-29 00:16:38.089: W/dalvikvm(3260): threadid=1: thread exiting with uncaught exception (group=0xb587f4f0)
06-29 00:16:38.089: E/AndroidRuntime(3260): FATAL EXCEPTION: main
06-29 00:16:38.089: E/AndroidRuntime(3260): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { act=android.intent.action.VIEW dat=content://org.openintents.filemanager/mimetype//mnt/sdcard/download/02977_awreckedboatintheocean_1280x1024.jpg }} to activity {com.polygonattraction.testbirds/com.polygonattraction.testbirds.functions.SelectImageSource}: java.lang.IllegalStateException: Can't compress a recycled bitmap
06-29 00:16:38.089: E/AndroidRuntime(3260): …Run Code Online (Sandbox Code Playgroud) 我在收音机组内有2个单选按钮.现在他们垂直排队.我尝试将它们放在一个水平容器中,但它并没有后悔.
有没有办法让一组无线电按钮按顺序排列?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioGroup
android:id="@+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioChats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chats"
android:checked="true" />
<RadioButton
android:id="@+id/radioPlayers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Players"
android:checked="true" />
</RadioGroup>
<Button android:text="Home"
android:id="@+id/buthome"
android:paddingTop="-15dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:text="Players"
android:id="@+id/butplayers"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/viewActivePlayer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TedP"
android:layout_gravity="right"
android:textColor="#fffff109"
android:textSize="26dip" />
Run Code Online (Sandbox Code Playgroud)