小编Pir*_*aba的帖子

Android SharedPreferences如何保存/存储对象

我们需要在许多地方获取用户对象,其中包含许多字段.登录后,我想保存/存储这些用户对象.我们怎样才能实现这种情况?

我不能这样存储它:

SharedPreferences.Editor prefsEditor = myPrefs.edit();
prefsEditor.putString("BusinessUnit", strBusinessUnit);
Run Code Online (Sandbox Code Playgroud)

android sharedpreferences

188
推荐指数
6
解决办法
17万
查看次数

Android Toast消息未显示

我有Button.当用户点击按钮时,有一些条件,条件不满足则需要显示Toast但不显示Toast Message ...

代码:已编辑

 Button addMe = (Button)findViewById(R.id.addMe);
    addMe.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
               if(selectedReason.equals("--Select--")){
                   Log.i("TAG","-----");
                   Toast.makeText(getBaseContext(), "Reason can not be blank", Toast.LENGTH_SHORT).show();
               }else if(selectedType.equals("--Select--")){
                   Toast.makeText(getParent(), "Discount type can not be blank", Toast.LENGTH_SHORT).show();
               }else{
                   if(selectedType.equals("Value")){
                       if(spc_amount.getText().toString().equals("")){
                           Log.i("TAG","-----");
                           Toast.makeText(getBaseContext(), "Discount type can not be blank", Toast.LENGTH_SHORT).show();
                       }else{
                           if(Double.parseDouble(spc_amount.getText().toString()) > invoiceValue){
                               Toast.makeText(getBaseContext(), "Amonut can not be grater than invoice", Toast.LENGTH_SHORT).show();
                           }else{
                               Discount dis = new Discount();
                               dis.setCriteriaName(selectedReason);
                               dis.setDiscountValue(Double.parseDouble(spc_amount.getText().toString()));
                               spDisList.put(1,dis);
                               tl.removeAllViews();
                            loadTableLayout();
                           }

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

我曾尝试与语境getParent() …

android

54
推荐指数
11
解决办法
6万
查看次数

Cordova PhoneGap从2.2.0升级到5.1.1

我有Cordova应用程序,版本2.2.0.现在我要升级,我已经做了升级部分,升级后,应用程序图像不显示,它出现了空白屏幕.即使是闪屏也没来.这是我的代码

现在我达到了一定程度.我模拟的应用程序是关于SQLitePlugin问题.当Open数据库说db.cordova没有定义时

如何安装数据库 - 将数据库从db文件夹复制到android安装位置.这工作得很好.

这是我的数据库:

    var DB              = new Object();
DB.isDBSupported    = false;
DB.isDBCreated      = false;
DB.vocabDB          = null;
DB.tables           = ['userResponses', 'wordGroups', 'words', 'wordMapping', 'checkExists', 'patch_version']
DB.createdTables    = 0;
DB.setupCallback    = null;
DB.curQP            = null;
DB.accountStatus    = false;
DB.sfx              = true;
DB.showWarnings     = true;
DB.firstLaunch      = false;

DB.initDB = function(callback) {
    this.setupCallback = callback || function(){/*console.log("null function called")*/};
    this.openDB();
    var db = this;
    if(!isPhoneGap()) {
        _.delay(this.checkDB.bind(this), 500);
    }
}

DB.checkDB = function() {
    var db = …
Run Code Online (Sandbox Code Playgroud)

javascript java android phonegap-plugins cordova

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

如何从C#调用C++代码

我有C++代码.该代码包含Windows移动GPS启用/禁用功能.我想从C#代码中调用该方法,这意味着当用户单击按钮时,C#代码应该调用C++代码.

这是用于启用GPS功能的C++代码:

       #include "cppdll.h"

      void Adder::add()
      {
       // TODO: Add your control notification handler code here
          HANDLE hDrv = CreateFile(TEXT("FNC1:"), GENERIC_READ | GENERIC_WRITE,
                        0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
          if (0 == DeviceIoControl(hDrv, IOCTL_WID_GPS_ON, NULL, 0, NULL, 0, NULL, NULL))
          {
             RETAILMSG(1, (L"IOCTL_WID_RFID_ON Failed !! \r\n")); return;
          }
             CloseHandle(hDrv);

         return (x+y);
       }
Run Code Online (Sandbox Code Playgroud)

这是头文件cppdll.h:

       class __declspec(dllexport) Adder
       {
          public:
           Adder(){;};
          ~Adder(){;};
         void add();
        };
Run Code Online (Sandbox Code Playgroud)

如何使用C#调用该函数?

请问,有人可以帮我解决这个问题吗?

c# c++ c++-cli windows-mobile

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

Android sqlite回滚

我正在做数据库同步.在sql server和sqlite之间下载数据.如果在sqlite中更新/插入记录时存在某些情况,则互联网连接速度慢或丢失然后需要回滚.这可能在此代码中或如何在此处使用事务处理.

 public void insertTableRecords(String strTableName, String[] strToFields, String[] strValues){
    DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(DownlaodTableActivity.this);
    dbAdapter.openDataBase();
    ContentValues initialValues = new ContentValues();
    for(int i=0 ;i<strToFields.length;i++){
        initialValues.put(strToFields[i],strValues[i]);
    }
    long n = dbAdapter.insertRecordsInDB(strTableName, null, initialValues);
    System.out.println( " -- inserted status : --- " + n);
}
Run Code Online (Sandbox Code Playgroud)

请帮我.

提前致谢...

sqlite android

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

Android Parcelable - RetailerOrderActivity.java返回null

我必须将一个活动传递给另一个活动:

我有SalesProduct enetity类:

 public class Product implements Parcelable{

    private double availableQuantity;
    private double price;
    private String productCode; 
    private String description; 
    private String description2;
    private String productGroup;
    private String alternateSearch;
    private String productTypeCode; 
    private String nonStockItemFlag;
    private String salableFlag;
    private double weight;
    private double qty;
    private double grossValue;
    private double value;
    private ArrayList<Product> product;


    public Product() {

    }
    public Product(Parcel in) {
         this();
          readFromParcel(in);
    }

       /*
       * Constructor calls read to create object
       */
       private void readFromParcel(Parcel in) {
          in.readTypedList(product, Product.CREATOR); …
Run Code Online (Sandbox Code Playgroud)

android

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

导入com.google.android.maps.geopoint无法解析

我有Java GoogleMAP项目.这不是android项目.我之前使用KML完成了这个项目.现在谷歌已经改为JSON/XML.我需要在数据库-postgresql中的2个位置保存坐标.然后累计到我将在MAP中绘制路径.

现在的问题是:GeoPoint cannot be resolved to a type.我也这样导入import com.google.maps.GeoPoint;.这也显示为红色标记.请让我知道什么是问题或问题?

我谷歌吧.没运气.所有提到有关Android谷歌api设置.

不是android项目......

请帮我..

提前致谢.

java google-maps map google-maps-api-3

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

将ArrayList转换为HashMap

可能重复:
Java:如何将List转换为Map

我有arrayList

ArrayList<Product> productList  = new ArrayList<Product>();
 productList  = getProducts();  //Fetch the result from db
Run Code Online (Sandbox Code Playgroud)

我想将ArrayList转换为HashMap,就像这样

  HashMap<String, Product> s= new HashMap<String,Product>();
Run Code Online (Sandbox Code Playgroud)

请帮我看看如何转换为HashMap.

java

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

Android无法连接到相机服务

当用户点击相机时,它会在几秒钟之后打开下一个屏幕 Fail to connect to camera service

它说 cannot connect to camera

这是我的代码:

   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View viewLoad = LayoutInflater.from(CameraActivity.this).inflate(R.layout.camera, null);
    setContentView(viewLoad);

    Bundle bundle = this.getIntent().getExtras();
    seletctedRetailer = bundle.getString("RetailerName");
    retailerCode = bundle.getString("RetailerCode");

    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
    Bundle b = new Bundle();
    b.putString("Activity", "RetailerOrderSActivity");
    b.putString("RetailerName", seletctedRetailer);
    b.putString("RetailerCode", retailerCode);

    cameraIntent.putExtras(b);
    getParent().getParent().setTitle("Image Capture");
    startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST);  

    vale +=1;

    Button imgMCancel =(Button)findViewById(R.id.imgMCancel);
    imgMCancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(getBaseContext(), CameraMainActivity.class);
            Bundle bundle = new Bundle(); 
            bundle.putString("Activity", …
Run Code Online (Sandbox Code Playgroud)

android

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

单击完成键时,Android OnEditorActionListener()actionId给0

我创建了一个键盘.当用户输入数字时,它输入特定的EditText.But当用户点击Done键时,它没有进入setOnEditorActionListener但关闭键盘.

这是我的代码:

 final EditText txtQty = new EditText(this);
        txtQty.setHeight(1);
        txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 42));
        txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
        txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
        txtQty.setSelectAllOnFocus(true);
        txtQty.setTextSize(9);
        txtQty.setVisibility(View.VISIBLE);
        txtQty.setHint("0.0");
        txtQty.setHighlightColor(R.color.green);
        tr.addView(txtQty);
 txtQty.setOnEditorActionListener( new OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                Log.i("KeyBoard" ,"Inside the Edit Text");
                if (actionId == EditorInfo.IME_ACTION_DONE ||actionId == EditorInfo.IME_ACTION_NEXT ) { ......}
Run Code Online (Sandbox Code Playgroud)

这里给出actionId = 0和EditorInfo.IME_ACTION_NEXT = 5

当我通过Android Softkeyboard运行它的工作正常

 txtQty.setOnEditorActionListener( new OnEditorActionListener() {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                Log.i("KeyBoard" ,"Inside the Edit Text");
                Log.i("---EditorInfo.IME_ACTION_NEXT---" , EditorInfo.IME_ACTION_NEXT); …
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard

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