resultString是我从sqlite获得的参数
resultString = result.getString(result.getColumnIndex(1));
Run Code Online (Sandbox Code Playgroud)
我想比较忽略情况和用户输入,以下是我使用的代码.但它不起作用.
例如,在数据库中,我存储用户名"George"当我登录时,我必须输入"George"."george"不起作用.
这是我要比较的代码.
if (userName.equalsIgnoreCase(resultString)) {
return true;
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?
<uses-permission>在应用程序和活动标签中请求权限使用和android:permission有什么区别?
当我只使用:
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
Run Code Online (Sandbox Code Playgroud)
该应用程序运行正常,但如果我也使用:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"
android:permission="android.permission.WAKE_LOCK">
Run Code Online (Sandbox Code Playgroud)
甚至:
<activity android:name=".android.Everlong"
android:label="@string/app_name" android:screenOrientation="portrait"
android:permission="android.permission.WAKE_LOCK">
Run Code Online (Sandbox Code Playgroud)
由于安全性错误,该应用无法启动...
首先,我做了一些谷歌,并发现IE'有条件的评论',并理解它是非标准的.我也得到的印象是没有标准的HTML'IF',所以我的问题是我需要做些什么来达到同样的效果(也许是Javascript?)...
我想有条件地包含一个外部.html文件(来自一系列外部.html文件).具体来说,外部文件每个只包含<meta>一行中的元素.或者,是否可以<meta>在HTML文件中包含多个内联元素,并有条件地"选择"一个元素(有效地忽略其他元素)?
基本上,我可以做一些与这些伪代码示例中的任何一个相同的东西吗?
使用外部文件的伪代码示例...
<html>
<head>
if some-condition
<!--#include file="meta1.html" -->
else
<!--#include file="meta2.html" -->
...
</head>
...
</html>
Run Code Online (Sandbox Code Playgroud)
用于直接选择替代元素的替代示例(再次伪代码)
<html>
<head>
if some-condition
<meta name="viewport" content="abc" />
else
<meta name="viewport" content="def" />
...
</head>
...
</html>
Run Code Online (Sandbox Code Playgroud)
注意:在所有情况下,<meta name属性将始终是viewport- 它只是content需要更改的属性,可能还有其他一些属性.
编辑:主要条件是客户类型.一个示例是,为了帮助在Android设备上正确调整Web应用程序页面的大小,您可以使用某些content数据viewport,只有Android设备才能理解.对于传统浏览器,我会为content(例如宽度/高度)设置一组默认数据.这也可以扩展到其他客户端,如谷歌电视,iOS等.
是否有一个合法的"通用"包名称,我可以用它来开源一些演示代码?
我想通过谷歌代码或任何地方提供演示Android应用程序作为"公共域"的来源,但我希望源程序包是"通用的".换句话说,我确实有一个我通常用于包命名的注册域名,但我宁愿没有那个用于演示代码的域名.
我有时会看到示例代码包com.example.some.package(例如),但这是一个注册域名.是否有任何常用的方法来命名不使用某人注册域名的通用包?
在我的应用程序中,我使用listview并通过扩展标准数组适配器来定制关联的数组适配器.但是,在扩展适配器中,我无法将视图声明声明为静态内部类.Eclipse不断给出"静态类型只能在静态或顶级类型中声明"的错误.这是代码:
public class IconicAdapter extends ArrayAdapter<String>
{
public static class ViewHolder
{
public TextView text;
public ImageView image;
}
public IconicAdapter() {
super(MainActivity.this,R.layout.row,values);
// TODO Auto-generated constructor stub
}
public View getView(int position,View convertView, ViewGroup parent)
{
View row = convertView;
if(row == null)
{
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.row, parent,false);
}
TextView label =(TextView)row.findViewById(R.id.label);
label.setText(values[position]);
ImageView icon = (ImageView)row.findViewById(R.id.icon);
icon.setImageResource(R.drawable.ok);
return (row);
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议吗?
我正在努力学习开发Android应用程序.我按照http://developer.android.com上的步骤操作,为Android设置了我的eclipse环境.我能够启动Android应用程序并启动模拟器并加载应用程序.
虽然每次都要超过30秒.我认为这应该是第一次需要一段时间,但在那之后就好了.这是正常的吗?
当它首次加载时,2-3个命令提示框出现并很快消失.然后它用下划线闪烁一段时间说"ANDROID _",然后再次显示单词android但是用一种花哨的字体.然后应用程序最终加载.
如果重要的话,我正在使用Win7x64.
我正在编写一个应用程序,需要显示地址,以便我以后可以使用它.我从LocationManager获取位置,并希望在按下时显示显示地址的Toast.我的问题是,当按下按钮时,没有任何反应.(甚至没有在LogCat中)
这是代码:
Button getTaxi = (Button) findViewById(R.id.GetTaxi);
getTaxi.setOnClickListener(new View.OnClickListener() {
public void getAddress() {
Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault());
String result = null;
try {
List<Address> list = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
if (list != null && list.size() > 0) {
Address address = list.get(0);
// sending back first address line and locality
result = address.getAddressLine(0) + ", " + address.getLocality();
}
} catch (IOException e) {
String exception = String.format("IOException!!");
Toast.makeText(getApplicationContext(), exception, Toast.LENGTH_LONG);
} finally {
if (result != …Run Code Online (Sandbox Code Playgroud) 我一直在寻找无所作为.我知道有几个问题,但我找不到一个适合我的问题.
基本上,我有一个活动(MainActivity),具有向主屏幕添加快捷方式的功能.当我单击快捷方式时,我希望它打开另一个活动(NewActivity).这里的搁置似乎是当我尝试启动与创建快捷方式的活动不同的活动时,它无法正常工作.
快捷方式成功完成,但是当我点击它时,我从Android系统得到一个"App not not installed"toast消息.
这是添加快捷方式的代码:
Intent shortcutIntent = new Intent();
shortcutIntent.setClassName("com.enceladus.myApp", "com.enceladus.myApp.NewActivity");
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Calculator");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(MainActivity.this, R.drawable.calc));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
MainActivity.this.sendBroadcast(addIntent);
Run Code Online (Sandbox Code Playgroud)
编辑:这是我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.enceladus.myApp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.enceladus.myApp.NewActivity"
android:label=""
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:launchMode="singleInstance"
/>
</application> …Run Code Online (Sandbox Code Playgroud) 我的LogCat说:
java.lang.RunTimeException: Unable to instantiate activity ComponentInfo{com.erikbalen.idealgaslawcalculator/com.erikbalen.idealgaslawcalculator.NumberActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity{ActivityThread.java:2121}
Run Code Online (Sandbox Code Playgroud)
这是我的java文件:
public class NumberActivity extends Activity {
EditText pressure = (EditText) findViewById(R.id.editTextPressure);
EditText temperature = (EditText) findViewById(R.id.editTextTemperature);
EditText volume = (EditText) findViewById(R.id.editTextVolume);
TextView answer = (TextView) findViewById(R.id.textViewSolve);
Button solve = (Button) findViewById(R.id.buttonSolve);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_number);
solve.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
double pressureValue = Double.parseDouble(pressure.getText().toString());
double temperatureValue = Double.parseDouble(temperature.getText().toString());
double volumeValue = Double.parseDouble(volume.getText().toString());
double r = 0.0821;
double answerValue = (pressureValue*volumeValue)/(r*temperatureValue);
answer.setText(Double.toString(answerValue)); …Run Code Online (Sandbox Code Playgroud) 我有一个json文件.所以,我解析了json文件,我想jsonarray.length()在应用程序中共享值的所有类.那么,建议的方法是什么?