小编P. *_*ohm的帖子

使用带有ormlite的原始sql获取游标

我想将SimpleCursorAdapter与Spinner一起使用.

我找到了如何返回Cursor.

QueryBuilder<ChoixPointVerification, Integer> qb = choixPointVerificationDao.queryBuilder();
qb.where().eq(FIELD, id);
PreparedQuery<ChoixPointVerification> preparedQuery = qb.prepare();
AndroidCompiledStatement compiledStatement =
                (AndroidCompiledStatement)preparedQuery.compile(db, StatementType.SELECT);

Cursor cursor = compiledStatement.getCursor();
return cursor;
Run Code Online (Sandbox Code Playgroud)

但是Spinner需要一个_id字段,而我只有一个带有id字段的对象.我宁愿避免重命名这个领域.

我该如何解决这个案子?我真的需要将id与所有微调器字段相关联.

我想我可以从rawsql发出一个游标但是我找不到如何使用ormlite.如果我可以使用原始sql创建PreparedQuery似乎是可能的.

我还读到,如果我有一个AndroidDatabase对象,我可以发出一个Cursor对象,但是我们如何用ormlite创建一个AndroidDatabase呢?

我真的很开心所有的解决方案

问候

android ormlite

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

从Nhibernate 3.3获取SqlConnection

我想将Pivot与nhibernate 3.3的命名查询一起使用,并在GridView中使用它。

我在NHibernate,数据透视表和/或GetNextID()上看到可以使用结果转换器,但是我无法预测将是哪个字段。(所以我认为不可能有一个bean,我需要命名列)

因此,最好的解决方案是使用命名查询并将其放在DataTable中。

有没有一种简单的方法来获取数据并将其放入DataTable中。一种方法是从nhibernate检索SqlConnection并使用它检索存储过程返回的数据。但是有人会怎么做?

问候

c# nhibernate

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

包含在Android ListView中的EditText的内容不会保存

在我的项目中,我必须向用户显示一个基本上包含EditText的ListView.

这就像一份调查问卷,当他回答问题时,他可以下来回答下一个问题.(并回去)

public class onAdapter extends BaseAdapter {
    List<PointVerification> mObjects;
    Context mContext;
    LayoutInflater mInflater;

    HashMap<Integer, List<ChoixPointVerification>> mChoix;
    HashMap<Integer, ReponsePointVerification> mReponses;
    HashMap<Integer, String> mReponsesActuel;
    Integer mPositionSelectionne;
    Integer mIdIntervention;


    /**
     * Constructeur
     * @param context

     * @param listePointsVerification Liste des points de vérification à afficher.
     * @param listeChoixPointsVerification liste des choix de points de vérification pour chaque point de vérification.
     * @param listeReponsesPointsVerification réponses déjà fournies pour chaque point de vérification
     * @param idIntervention Identifiant de l'intervention
     */
    public onAdapter(
            Context context, …
Run Code Online (Sandbox Code Playgroud)

java android android-listview

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

喷气背包组合导航旋转后数据丢失

当我在 jetpack compose 中旋转我的应用程序(带导航)时,所有数据都会重置

每次旋转后,它都会进入 Activity 的 onCreate 并再次创建 NavHost 和 ViewModel。我认为这会通过应用程序状态来处理

例子

起始活动:

class NavActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            MyAppTheme() {
                MyAppApp()
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

包含 NavHost 的应用程序:

@Composable
fun MyAppApp(
    appState:  MyAppAppState = rememberAppState()
) {
        NavHost(
            navController = appState.navController,
            startDestination = Screen.ProductAddPath.route
            )
        {
            composable(Screen.ProductAddPath.route) {
                ProductEditView(
                    vm = ProductEditViewModel (appState.context)
                )
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

视图模型:

class ProductEditViewModel(context: Context) : ViewModel() {

    private val _productName = MutableStateFlow("qsd")
    val productName = …
Run Code Online (Sandbox Code Playgroud)

android-navigation android-jetpack-compose

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

比较2个字符串类型的字符串和LPWSTR

我想一个比较string例如"Tedt2.csv"&value这是LPWSTR在函数的声明.这是我的基本代码:

PWSTR   value = nullptr;
HRESULT hr    = properties->GetStringValue(key, &value);
Run Code Online (Sandbox Code Playgroud)

我测试了许多approches

if (wcsstr(&value, L"Tedt2.csv") == 0)
{
   wprintf(L"%ws: %ws\n", keyName, value);
}
Run Code Online (Sandbox Code Playgroud)

但它总是进入if.

有谁可以帮助我吗?它应该是微不足道的,但我有点迷失C++.我要做一个概念证明.

c++ string pointers

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