小编Had*_*adi的帖子

从资产中读取unicode文本

试图在android中读取一个utf-8编码的文件...

InputStreamReader reader = new InputStreamReader(assets.open("data.txt"), "UTF-8");
BufferedReader br = new BufferedReader(reader); 
String line;
//The line below throws an IOException!!
line = br.readLine();
Run Code Online (Sandbox Code Playgroud)

这段代码出了什么问题?

unicode file-io android

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

wxpython 3.0打破了较旧的应用程序?(区域设置错误)

我有一个适用于wxpython旧版本的应用程序

现在使用wxpython 3.0,在尝试运行应用程序时,我收到以下错误

  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_controls.py", line 6523, in __init__
    _controls_.DatePickerCtrl_swiginit(self,_controls_.new_DatePickerCtrl(*args, **kwargs))
wx._core.PyAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL), "C") == 0" failed at ..\..\src\common\intl.cpp(1449) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!
Run Code Online (Sandbox Code Playgroud)

错误来自这一行

File "C:\Users\hadi\Dropbox\Projects\Python\dialysis\profile.py", line 159, in __init__
    style=wx.DP_DROPDOWN)
Run Code Online (Sandbox Code Playgroud)

非常感谢帮助

python wxpython python-2.7

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

对话框中的微调器 - NullPointerException

我想用微调器显示自定义对话框.奇怪的是,当我尝试设置微调器的适配器时,我得到NullPointerException ...

Dialog dialog = new Dialog(this.getApplicationContext());
dialog.setContentView(R.layout.dialog_spinner);

ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, new String[] {"0","1","2"});

spin = (Spinner)dialog.findViewById(R.id.spinQ);
//What am I doing wrong here?
spin.setAdapter(spinnerAdapter);

dialog.setTitle("Questions");
dialog.show();
Run Code Online (Sandbox Code Playgroud)

xml布局代码:

<?xml version="1.0" encoding="utf-8"?>  

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:paddingLeft="10dip"
>

<Spinner 
android:id="@+id/spinQ" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
/> 


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

更新:

        AlertDialog alertDialog;


        LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.dialog_spinner,
                                       (ViewGroup) findViewById(R.id.root));

        ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this,
              android.R.layout.simple_spinner_item, new String[] {"0","1","2"});
        spin = (Spinner) findViewById(R.id.spinQ);
        //I get the error in the following …
Run Code Online (Sandbox Code Playgroud)

android dialog spinner

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

领域移动平台,离线时如何连接?

新领域移动平台通过离线支持进行广告宣传,但是大多数教程都没有显示示例中的工作方式......

例如,在他们的todo应用程序示例中,这是用于连接到服务器数据库的代码

SyncUser.logIn(with: .usernamePassword(username: username, password: password, register: false), server: URL(string: "http://127.0.0.1:9080")!) { user, error in
guard let user = user else {
    fatalError(String(describing: error))
}

DispatchQueue.main.async {
    // Open Realm
    let configuration = Realm.Configuration(
        syncConfiguration: SyncConfiguration(user: user, realmURL: URL(string: "realm://127.0.0.1:9080/~/realmtasks")!)
    )
    self.realm = try! Realm(configuration: configuration)

    // Show initial tasks
    func updateList() {
        if self.items.realm == nil, let list = self.realm.objects(TaskList.self).first {
            self.items = list.items
        }
        self.tableView.reloadData()
    }
    updateList()

    // Notify us when Realm changes
    self.notificationToken = …
Run Code Online (Sandbox Code Playgroud)

realm swift realm-mobile-platform

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