小编Bru*_*eri的帖子

android.database.sqlite.SQLiteCursor@435b9ba0

我收到了从spinner.getSelectedItem().toString()调用返回的文本'android.database.sqlite.SQLiteCursor@435b9ba0'.我不知道为什么.微调器绑定到SimpleCursorAdapter.

这是代码

    cCategories = (Cursor) myAdapter.getAllCategories();
    this.startManagingCursor(cCategories);

    SimpleCursorAdapter scaCategories = new SimpleCursorAdapter(this, R.layout.track_category_item,cCategories,new String[] {DBAdapter.KEY_CATEGORIES_NAME},new int[]{R.id.text1});
    scaCategories.setDropDownViewResource(R.layout.track_category_dropdown_item); 
    mCatSpinner = (Spinner) findViewById(R.id.thecategory);
    mCatSpinner.setAdapter(scaCategories);

    if(mCatSpinner.isSelected() != true) {
        mCatSpinner.setSelection(0);
    }
Run Code Online (Sandbox Code Playgroud)

和xml track_category_item.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:ellipsize="marquee"
    android:singleLine="true">
</TextView>
Run Code Online (Sandbox Code Playgroud)

track_category_dropdown_item.xml

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"           
    android:id="@+id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="true"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:ellipsize="marquee" />
Run Code Online (Sandbox Code Playgroud)

spinner xml看起来像这样

<Spinner
    android:id="@+id/thecategory"
    android:prompt="@string/SELECT_CATEGORY"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_x="15px"
    android:layout_y="133px" >
</Spinner>
Run Code Online (Sandbox Code Playgroud)

并且返回的光标是

public Cursor getAllCategories() 
{
    return db.query(DATABASE_CATEGORIES_TABLE, new String[] {
            KEY_CATEGORIES_ROWID,
            KEY_CATEGORIES_NAME,
            KEY_CATEGORIES_DEFAULT}, 
            null, 
            null, 
            null, 
            null, 
            null);
} …
Run Code Online (Sandbox Code Playgroud)

android spinner android-widget

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

以编程方式在appdelegate中创建tabBarController

我一直在关注如何以编程方式添加UITabBarController的不同教程.这很容易使用故事板来实现,但是因为我正在尝试以编程方式学习如何做事我无法做到这一点.目前我已经有了这个代码didFinishLaunchingWithOptions.

tabBarController = [[UITabBarController alloc] init];

NSMutableArray *tabs = [[NSMutableArray alloc] init];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[[MenuViewController alloc] init]];

[tabBarController setViewControllers:tabs];

[tabs addObject:navController];


[self.window addSubview:tabBarController.view];
Run Code Online (Sandbox Code Playgroud)

编辑代码:

tabBarController = [[UITabBarController alloc] init];

MenuViewController *firstTab = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstTab];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[navController];
[self.window setRootViewController:tabBarController];
[self.window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)

这对于我的rootViewController调用MenuViewController没有任何意义.我怎样才能实现这一目标?

objective-c uitabbarcontroller ios

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

使用常规PhantomReference类删除本机对等项

正如Google I/O '17中的Hans Boehm所说的" 如何在Android中管理本机C++内存 "建议我使用PhantomReference该类来确保正确删除本地对等体.

18分57秒的链接视频中,他展示了一个对象的示例实现,该对象将其自身注册到PhantomReference类的类型.这PhantomReference节课,他以19分49秒的成绩表演.所以我为我的示例对象复制了他的方法.见下文.

虽然这种方法很好,但它不能扩展.我将需要创建相当多的对象,我还没有找到一种方法来创建一个基类(对于我的对象或PhantomReference基类),它将接受任何对象,并将正确处理本机删除.

如何创建一个PhantomReference可以在提供的对象上调用本机静态方法的通用基类?

我试图转换PhantomReference泛型,但本机静态删除方法阻碍了实现.

我的 WorkViewModel

import android.databinding.*;

public class WorkViewModel extends BaseObservable
{
  private long _nativeHandle;

  public WorkViewModel(Database database, int workId)
  {
    _nativeHandle = create(database.getNativeHandle(), workId);
    WorkViewModelPhantomReference.register(this, _nativeHandle);
  }

  private static native long create(long databaseHandle, int workId);
  static native void delete(long nativeHandle);

  @Bindable
  public native int getWorkId();
  public native void setWorkId(int workId);
}
Run Code Online (Sandbox Code Playgroud)

我的 WorkViewModelPhantomReference

import …
Run Code Online (Sandbox Code Playgroud)

java android memory-management phantom-reference

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

Sherlock Action Bar带滑动菜单

我正在制作一个视图和一个扩展SherlockMapActivity的活动,并使用SlidingMenu库使我的主视图像Google+一样滚动.我已经通过XML添加了SlidingMenu,我的视图滚动完美地显示隐藏的菜单,但它只滚动操作栏下方的视图.在Google+应用中,它还会滚动操作栏,我看到有一个功能可以让我的操作栏滑动启用,但它不起作用.

什么是使我的操作栏与完整视图一起滑动的最佳方法?也许我没有扩展正确的课程?

这是我将SlidingMenu添加到我的应用程序的方式:

XML文件:

<com.slidingmenu.lib.SlidingMenu
    xmlns:sliding="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slidingmenulayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    sliding:viewAbove="@layout/activity_main"
    sliding:viewBehind="@layout/menu_desplegado"
    sliding:behindOffset="120dip"
    sliding:behindScrollScale="0.25"
 />
Run Code Online (Sandbox Code Playgroud)

这就是结果:

主要布局截图

android menu sliding actionbarsherlock

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

在长按中将Android中的图标作为iPhone摇动

我正在实现一个应用程序,我想在iPhone中摇动图标.

我该如何实现呢?

我在这里附上了动画的代码.请建议我任何解决方案.我已经尝试了已经在堆栈溢出中指定的soln,但它在我的情况下不起作用.此类是一个非活动类,其中编写了此动画集.

protected void animateDragged(){
    View v = getChildAt(dragged);
    int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
    int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
    v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
    AnimationSet animSet = new AnimationSet(true);
    ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * …
Run Code Online (Sandbox Code Playgroud)

animation android

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

使用android中的alertbox弹出窗口从gridview更新数据库

我正在使用Android中的网格视图为商店开发客户详细信息.我使用我的数据库获取了客户的详细信息.我需要使用警报框更新客户处理的股票,以便在执行交易时输入库存数量.

customergrid.xml

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

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/tab1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" >

      <GridView
          android:id="@+id/grid"
          android:layout_width="fill_parent"
          android:layout_height="357dp"
          android:numColumns="1"
          android:stretchMode="columnWidth" />

      <Button
          android:id="@+id/cancel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="cancel" />

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

并且,对于每一行,我使用了自定义的Xml文件..

customerrow.xml

 <?xml version="1.0" encoding="utf-8"?>
 <TableLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent" >
     <TableRow>
         <TextView
             android:layout_width="50px"
             android:layout_height="wrap_content"
             android:id="@+id/row_ID"
             android:padding="5px"
             android:layout_weight="1" />
         <TextView 
             android:layout_width="50px"
             android:layout_height="wrap_content"
             android:id="@+id/key_ID"
             android:padding="5px"
             android:layout_weight="1" />
         <TextView 
             android:layout_width="50px"
             android:layout_height="wrap_content"
             android:id="@+id/key_Description"
             android:padding="5px"
             android:layout_weight="1" />
     </TableRow>
 </TableLayout>
Run Code Online (Sandbox Code Playgroud)

我在Oncreate()方法上使用了customergrid.xml,并在Grid创建中使用customerrow.xml,如下面的代码所示.

 public void FillGrid() {
     DatabaseHelper sqdb = new DatabaseHelper(this);
     sqdb.openDataBase();
     Cursor cursor;
     GridView grid = (GridView) findViewById(R.id.grvData);
     cursor = …
Run Code Online (Sandbox Code Playgroud)

android android-gridview android-alertdialog

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

Android:如何在xml中将自定义surfaceview设置为固定大小的比例?

我试图有一个surfaceview(一个扩展surfaceview的自定义类),我在xml布局中添加了一个固定大小比例:4:3(长度到宽度).

我希望它能够尽可能多地填充它的父级,无论是长度还是宽度,但是一旦它达到全长或宽度,它将调整另一侧以具有我之前说过的固定大小比率.

我怎么能做到这样的事情?

谢谢.

android surfaceview

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

如何在 XML 中引用字符串数组元素 (android)

如何访问字符串数组的元素

<string-array name="contextMenuItems">
    <item>Edit</item>
    <item>Info</item>
    <item>Delete</item>        
</string-array>
Run Code Online (Sandbox Code Playgroud)

来自另一个资源 xml 文件

<menu>
    <item android:id="@+id/Edit"
        android:title="@string/contextMenuItems" />
    <item android:id="@+id/Info"
        android:title="@array/contextMenuItems" />
</menu>
Run Code Online (Sandbox Code Playgroud)

xml android

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

如何将AdMob放置在屏幕顶部(上图)Android操作栏?

我尝试将AdMob广告放置在Android操作栏的屏幕顶部(上方). 上面的ActionBar AdMob

  • 黄色= ActionBar
  • 红色=内容
  • 绿色= AdMob

我发现的一个类似问题是在屏幕底部放置一个广告,并显示操作栏.但到目前为止,我无法弄清楚如何将它放在屏幕的顶部.

我这样试过:

private AdView adView;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // main view setup
    setContentView(R.layout.main);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // actionbar setup
    ActionBar actionBar = getActionBar();
    actionBar.setTitle("Search");
    actionBar.setDisplayHomeAsUpEnabled(true);

    final LinearLayout content = (LinearLayout) findViewById(android.R.id.content).getParent();

    // Create the adView
    adView = new AdView(this, AdSize.BANNER, "ID");

    // Lookup your LinearLayout assuming it’s been given
    // the attribute android:id="@+id/mainLayout"

    // Add the adView to it
    FrameLayout.LayoutParams parm = (FrameLayout.LayoutParams) content.getLayoutParams();
    parm.gravity = Gravity.TOP;
    content.addView(adView);

    // …
Run Code Online (Sandbox Code Playgroud)

android admob android-layout android-actionbar

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

单击 JMeter 中的 html 按钮

我需要单击一个添加按钮。我已经遍历到具有该按钮的页面,正如查看结果树中的响应数据所验证的那样。我尝试发出获取请求(发布按钮点击 URL),但这没有用。

下面是按钮的 HTML

<button 
    class="bigbutton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
    onclick="var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; if (win == window) { window.location.href='?x=KOGI5TeEN-U*JE6roI7oZMd-OfKSr5oQnRTh7tHdN*Bh66LwE2vEHDjxo9WFuOf7Ti2zcBh-IaE'; } ;return false" 
    style="float: right;" 
    role="button" 
    aria-disabled="false">
<span class="ui-button-text"> Add </span>
Run Code Online (Sandbox Code Playgroud)

html jmeter

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