小编Yoo*_*Yoo的帖子

从SQLite获取所有行

我一直在尝试从SQLite数据库中获取所有行.但是我从下面的代码中得到了最后一行.

FileChooser类:

public ArrayList<String> readFileFromSQLite() {

  fileName = new ArrayList<String>();

  fileSQLiteAdapter = new FileSQLiteAdapter(FileChooser.this);
  fileSQLiteAdapter.openToRead();
  cursor = fileSQLiteAdapter.queueAll();

  if (cursor != null) {
    if (cursor.moveToFirst()) {
      do {
        fileName.add(cursor.getString(cursor.getColumnIndex(FileSQLiteAdapter.KEY_CONTENT1)));
      } while (cursor.moveToNext());

    }
    cursor.close();
  }

  fileSQLiteAdapter.close();
  return fileName;
}
Run Code Online (Sandbox Code Playgroud)

FileSQLiteAdapter类:

public Cursor queueAll() {
  String[] columns = new String[] { KEY_ID, KEY_CONTENT1 };

  Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null,
                null, null, null, null);
  return cursor;
}
Run Code Online (Sandbox Code Playgroud)

请告诉我,我的错误在哪里.欣赏.

sqlite android

42
推荐指数
2
解决办法
10万
查看次数

从EditText获取String

login.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            if( username_text.getText().toString() == "admin" &&
                    pass_text.getText().toString() == "password"){

                startActivityForResult(i, ACTIVITY_CREATE);

            }else{
                Toast.makeText(gps_gui.this, "Your username or password is not correct! Please, insert again",
                        Toast.LENGTH_SHORT).show();
                clearEditText();
            }
        }

    });
Run Code Online (Sandbox Code Playgroud)

我试着检查它,我发现如果情况不行.

android if-statement android-edittext

15
推荐指数
1
解决办法
5万
查看次数

如何从平均海平面计算高度

我试图找到如何使海拔高于平均海平面.此时,它从椭圆体返回高度.因此,任何人都知道公式或计算将高度值从椭球改变为平均海平面的高度值.

谢谢你的帮助

android geolocation altitude

10
推荐指数
1
解决办法
2万
查看次数

在EditText中输入后,如何使键盘消失

从android教程:

pass_text.setOnKeyListener(new OnKeyListener() {
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        // If the event is a key-down event on the "enter" button
        if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
            // Perform action on key press
            return true;
        }
        return false;
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

单击EditText时,框架上会出现一个键盘.在Enter之后我想知道.除了单击Back,如何从框架中输出键盘.

在此输入图像描述

谢谢

keyboard android android-edittext

7
推荐指数
2
解决办法
2万
查看次数

只选择一个复选框

我有一个多个复选框,但我希望用户只选择一个复选框.我尝试if-else语句,但它不可用.所以,我想知道,怎么样那样.

谢谢

checkbox android

6
推荐指数
1
解决办法
3万
查看次数

第二次通知无效

我尝试创建多个通知.如果单击通知,它将链接到另一个活动.在下面的代码之后,它会创建两行通知.但是,当我点击第一行通知时,它无法正常工作.只有第二个工作.

for (int i = 0; i < missionName.size(); i++) {
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    final Notification notifyDetails = new Notification(R.drawable.icon,
            "Mission Completed, Click Me!", System.currentTimeMillis());
    notifyDetails.defaults |= Notification.DEFAULT_SOUND;
    notifyDetails.defaults |= Notification.DEFAULT_VIBRATE;
    Context context = getApplicationContext();
    CharSequence contentTitle = missionName.get(i) + " is completed";
    CharSequence contentText = "Please click to view the mission";
    Intent notifyIntent = new Intent(getApplicationContext(),MissionMap.class);
    notifyIntent.putExtra("missionName", missionName.get(i));
    PendingIntent intent = PendingIntent.getActivity(ApplicationMenus.this,
            0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);

    notifyDetails.setLatestEventInfo(context, contentTitle, contentText,
            intent);
    mNotificationManager.notify(i, notifyDetails);
}
Run Code Online (Sandbox Code Playgroud)

所以,请帮我找出我的错误.非常感谢.

android android-intent android-pendingintent

6
推荐指数
1
解决办法
1909
查看次数

设置HH:MM:天文台的SS

我知道计时器的格式可以是MM:SS或HH:MM:SS,但我想知道如何使用setFormat()和getFormat()来设置HH:MM:SS模式(现在是MM:SS).

这时,我使用: android:format="@string/chronometer_initial_format"通过声明设置Format:

<xliff:g id="initial-format">%1$s</xliff:g>
Run Code Online (Sandbox Code Playgroud)

在res/values/strings.xml

我试图通过谷歌搜索,但无法得到很好的答案.有人可以建议吗?谢谢

android chronometer android-widget

4
推荐指数
1
解决办法
1万
查看次数

通过JSON将数据从android发送到服务器

  1. 我有MySQL数据库服务器
  2. 我需要通过JSON更新和从MySQL服务器检索数据

所以,我想知道如何做到这一点,我非常混淆这个示例语句:

HttpPost httppost = new HttpPost("http://10.0.2.2/city.php");
Run Code Online (Sandbox Code Playgroud)

这意味着我需要编写与PHP服务器连接的应用程序,然后再编写php以连接到数据库吗?

php mysql android json

3
推荐指数
1
解决办法
3万
查看次数

Arcgis可用于Android吗?

我想为Android和Web服务开发Arcgis,但我不知道它有API吗?如果有的话,可以在地图上标记(比如谷歌地图API)我在我的服务器上收集了lat和long吗?

谢谢你:))

android web-services arcgis

1
推荐指数
1
解决办法
697
查看次数

按下按钮时如何进入下一个布局(不是活动)?

我想创建指令,所以当用户按下下一个按钮时我想设置为下一个布局页面.我试过,setContentView(R.layout.aboutus);但它似乎将新布局设置为特定页面.

布局:

 <?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:background="#dddddd">
        <LinearLayout android:gravity="center" android:background = "@drawable/aboutus"
            android:orientation="vertical" android:layout_height="wrap_content"
            android:layout_width="wrap_content"/>
    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

代码:

 public void onItemClick(AdapterView<?> parent, View view, int position,
                long lg) {
            switch (position) {

            case 4:
                setContentView(R.layout.aboutus);
            }

        }
Run Code Online (Sandbox Code Playgroud)

所以,我想知道如何在没有新活动的情况下进入下一个布局,并且可以返回上一页.谢谢.

layout android android-layout

0
推荐指数
1
解决办法
2284
查看次数