小编Abo*_*Kdz的帖子

如何在sqlite中使用ROW_NUMBER

这是我在下面给出的查询.

select * from data where value = "yes";
Run Code Online (Sandbox Code Playgroud)

我的id是自动增量,下面是给定查询的结果.

id || value 
1  ||   yes
3  ||   yes
4  ||   yes
6  ||   yes
9  ||   yes
Run Code Online (Sandbox Code Playgroud)

如何在sqlite中使用ROW_NUMBER?这样我就可以得到下面给出的结果.

NoId || value 
1    ||   yes
2    ||   yes
3    ||   yes
4    ||   yes
5    ||   yes
Run Code Online (Sandbox Code Playgroud)

ROW_NUMBER作为NoId.

sqlite row-number android-sqlite

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

使用文本和值从spinner sqlite加载

我有一个spinner加载数据到sqlite

我在数据库中有字段ID和字段名称.

private void loadSpinnerDataHama() {
        // database handler
        DatabaseSpinner db = new DatabaseSpinner(getApplicationContext()); 
        // Spinner Drop down elements
        List<String> lables = db.getAllLabels();
        // Creating adapter for spinner
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_spinner_item, lables);
        // Drop down layout style - list view with radio button
        dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        // attaching data adapter to spinner
        spin2.setAdapter(dataAdapter);
    }

    public List<String> getAllLabels(){
    List<String> labels = new ArrayList<String>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + TABLE_LABELS;

    SQLiteDatabase db = this.getReadableDatabase(); …
Run Code Online (Sandbox Code Playgroud)

android android-spinner

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

两个旋转器在一个活动中

我有2个旋转器.

这是我的活动

package com.example.belajarcombobox;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;


public class CreateComboBox extends Activity implements AdapterView.OnItemSelectedListener {

    TextView selection;
    TextView selection2;
    String[] countries = {"Amerika","Argentina","Brazil"};

    String[] city = {"London","Paris","Buenos Aires"};

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        selection = (TextView) findViewById(R.id.selection);
        Spinner spin = (Spinner) findViewById(R.id.spinner);
        ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, countries);
        aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spin.setAdapter(aa);
        spin.setOnItemSelectedListener(this);

        selection2 = (TextView) findViewById(R.id.selection2);
        Spinner spin2 = (Spinner) findViewById(R.id.spinner2);
        ArrayAdapter<String> bb = new …
Run Code Online (Sandbox Code Playgroud)

android android-spinner

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

使用C#中的按钮清除多个文本框

我使用.NET framework 4.

在我的表格中,我有41个文本框.

我尝试过这段代码:

private void ClearTextBoxes()
        {
            Action<Control.ControlCollection> func = null;

            func = (controls) =>
            {
                foreach (Control control in controls)
                    if (control is TextBox)
                        (control as TextBox).Clear();
                    else
                        func(control.Controls);
            };

            func(Controls);
        }
Run Code Online (Sandbox Code Playgroud)

这段代码:

private void ClearTextBoxes(Control.ControlCollection cc)
        {
            foreach (Control ctrl in cc)
            {
                TextBox tb = ctrl as TextBox;
                if (tb != null)
                    tb.Text = String.Empty;
                else
                    ClearTextBoxes(ctrl.Controls);
            }
        }
Run Code Online (Sandbox Code Playgroud)

这仍然不适合我.

当我尝试使用此代码TextBoxName.Text = String.Empty;清除时,文本框成功清除但只有一个文本框,仍然有40个文本框.

我该如何解决这个问题?

编辑

我投入了这个:

private void btnClear_Click(object sender, EventArgs e)
        { …
Run Code Online (Sandbox Code Playgroud)

c# textbox winforms

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

显示 NMEA 语句?

任何人都可以帮助显示 NMEA 句子,如 $GPRMC ..... 我正在使用以下代码:

public class SampleNMEA extends Activity implements LocationListener, GpsStatus.Listener,GpsStatus.NmeaListener{

    LocationManager lm;
    TextView output;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        output = (TextView)findViewById(R.id.out);
        lm = (LocationManager) getSystemService(LOCATION_SERVICE);

        lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this);
        final Location location=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);


        output.append("\nBelow Data is about the your location:");

        output.append("\n\n\nLatit:"+location.getLatitude());
        output.append("\n\nLongitude:"+location.getLongitude());
        output.append("\n\nTime: "+location.getTime());


    }
    public void onLocationChanged(Location location) 
    {
        output.append("\n\n\nLatitude:"+location.getLatitude());
        output.append("\n\nLongitude:"+location.getLongitude());
        output.append("\n\nTime: "+location.getTime());
    }

    public void onProviderDisabled(String arg0) {
        // TODO Auto-generated method stub

    } …
Run Code Online (Sandbox Code Playgroud)

android

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

检查值是否存在sqlite错误插入

我有一种方法来插入数据并检查代码是否存在

如果存在则不创建插入,如果不存在则创建插入

但是当我尝试运行数据时无法插入数据库

这是我的插入代码

public void processAddA(DialogWrapper wrapper)
               {
           ContentValues values = new ContentValues(2);

            values.put(DatabaseHelper.CODE, wrapper.getCode());
            values.put(DatabaseHelper.ALAMAT, wrapper.getAlamat());
            values.put(DatabaseHelper.BATAS, wrapper.getBatas());
            values.put(DatabaseHelper.LAT, wrapper.getLat());
            values.put(DatabaseHelper.LON, wrapper.getLon());
            values.put(DatabaseHelper.LUAS, wrapper.getLuas());
            values.put(DatabaseHelper.TANGGAL_AWAL, wrapper.getTglA());
            values.put(DatabaseHelper.TANGGAL_AKHIR, wrapper.getTglB());
            values.put(DatabaseHelper.USER_ID, wrapper.getUser());
            values.put(DatabaseHelper.SENT, "0");

                  open();
                  //check if value exist or not.
                  Cursor c = database.rawQuery("SELECT * FROM petak_tetap where code='"
                            + wrapper.getCode() + "'", null);
                  if(c == null)
                  {
                  //doesn't exists therefore insert record.
                      database.insert("petak_tetap", DatabaseHelper.ALAMAT,
                                values);
                  }
                  close();
               }
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题?

android

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

java.lang.classcastexception android.widget.textview错误来自android但我看不出怎么样

第一次发布,自我思考的程序员,并在android中有一个类强制转换异常.我明白错误是什么,我知道是什么导致了它,但我不知道它为什么会发生.

public class ChangeTwitter extends Activity {

EditText newtwitter;
EditText password;
Button submitbutton;

InputStream is = null;
String result = "";
private static String passwordchecker;

FUNCTIONS callfunction = new FUNCTIONS();
ERRORS callerrors = new ERRORS();

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.twitterchanger);



    try
    {
        newtwitter = (EditText) findViewById(R.id.twitterchangertwitter);
            password = (EditText) findViewById(R.id.twitterchangerpassword);
            submitbutton = (Button) findViewById(R.id.twitterchangersubmitbutton);
    }

    catch (Exception e)
    {
        Log.e("log_tag", "Error is:"+e.toString());
    }
Run Code Online (Sandbox Code Playgroud)

public class ChangeTwitter extends Activity {

<TextView 
        android:text="" 
        android:id="@+id/twitterchangerspacer1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">
    </TextView>
    <TextView 
        android:text="Please …
Run Code Online (Sandbox Code Playgroud)

java android

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