问题列表 - 第29275页

为什么'x'用于[x"$ VAR"= x"VALUE"]?

我可以在unix shell脚本中看到后续构造使用

[ x"$VAR" = x"VALUE" ] 
Run Code Online (Sandbox Code Playgroud)

代替

[ "$VAR" = "VALUE" ] 
Run Code Online (Sandbox Code Playgroud)

为什么?

unix shell

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

Android ListView页脚视图未放置在屏幕底部

我确信我错过了一些简单的方法来实现这一点,但是我已经完成了所有已知的组合,以便得到我正在寻找的工作.当ListView项目没有填满页面时,我正试图让ListView页脚位于屏幕底部.

例如,我有一个包含三个项目的ListView的页面和一个FooterView(使用ListView的addFooterView)我希望footerView位于屏幕的底部.当ListView包含足够的项目来滚动屏幕时,footerView应该位于列表的末尾(而不是位于屏幕的底部).

我正在尝试使用的XML如下所示.任何和所有的帮助非常感谢!

Layout.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@+drawable/background">
<ListView
    android:id="@+id/menu" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:listSelector="@android:color/transparent"
    android:divider="@null">
</ListView></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

ListViewRow.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
style="@style/Nationwide.menu">
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/nav_item"
    style="@style/Nationwide.menu.row">
    <ImageView 
        android:id="@+id/image_icon"
        style="@style/Nationwide.menu.leftIcon" />
    <TextView 
        android:id="@+id/nav_text" 
        style="@style/Nationwide.menu.text" />
    <ImageView
        android:id="@+id/chevron_symbol"
        style="@style/Nationwide.menu.rightIcon" />
</LinearLayout>
<View
    android:layout_height="1dp"
    android:background="@drawable/nav_item_divider_dark" />
<View
    android:layout_height="1dp"
    android:background="@drawable/nav_item_divider_light" /></LinearLayout>
Run Code Online (Sandbox Code Playgroud)

ListViewFooter.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true">
<View 
    android:id="@+id/footer_image"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true" /></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Java的

    LayoutInflater inflater = this.getLayoutInflater();
    View footerView = inflater.inflate(R.layout.footer, null);

    footerView.findViewById(R.id.footer_image).setBackgroundDrawable(resources.getDrawable(R.drawable.cone_footer));

    mMenuListView.addFooterView(footerView);
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试过的事情包括:

  • 添加页脚视图如上所示
  • 在ListView上添加可绘制资源作为背景(这导致ListView不会跨越屏幕的整个宽度,并且由于9-Patch可伸缩区域而以奇怪的方式滚动) …

android listview footer

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

iPhone - 处理UIViewController中的触摸幻灯片

我想在UIViewController子类中处理触摸(特别是水平幻灯片),但问题是控制器的视图包含覆盖整个屏幕的UIScrollView,因此从不调用"touchesBegan:"和"touchesEnded:"事件在我的控制器中.scrollview只能垂直滚动.

什么是使它能够处理这些事件的最佳方法?让我的UIViewController也继承UIScrollView并根据需要处理触摸(并删除当前的滚动视图),或使用UIScrollView子类代替我当前的滚动视图,它将调用我需要的情况的委托方法?或许还有另一种方式?

这是我目前的代码:

// View creation and adding to parent
NewViewController* newViewController = [[newViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self.view addSubview:newViewController.view];

// NewViewController.h
@interface NewViewController : UIViewController {
    IBOutlet UIScrollView*  scrollView;

    // other outlets and properties
}
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event;
Run Code Online (Sandbox Code Playgroud)

在IB中,NewViewController的视图包含scrollView,其中包含所有其他插座(标签,按钮)......目标是让NewViewController的scrollView调用NewViewController的touchesBegan和touchesEnded方法.

更新: ScrollViewSuite帮助我理解了如何处理触摸回调.UIScrollView只有在触摸不能滚动时才调用它们.

那么,有三种情况:

  • 倾斜滑动(一旦滚动条出现,即使稍微滑动):不touches调用任何方法
  • 完美的横向滑动(未出现滚动条)touchesBegan,touchesMovedtouchesEnded被称为
  • 任何触摸不引起随后稍微上下滑动的滚动(触摸不移动,或水平移动): touchesBegan,touchesMovedtouchesCancelled是调用;

可以通过设置UIScrollView's canCancelContentTouches来避免触摸取消,FALSE但这显然只有touchesBegan在被调用时才有效,这意味着第一种情况下仍然不会调用触摸方法.

但是UIScrollView有一个名为delaysContentTouches的属性TRUE,默认设置为,并且当触摸开始时它会等待一点,以便查看它是否会让他滚动.如果设置为FALSE,则触摸开始后立即调用touches方法,并允许子类按照自己的意愿处理它们. …

iphone cocoa-touch uiscrollview uiviewcontroller

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

知道如何将这个O(n ^ 2)算法转换为O(n)

我有以下算法扫描大型圆形阵列(数据).在数组中的某个点,我需要查看过去的值(0 =最新数据点,n =最旧的数据点)并确定是否有比当前值低5%的值.我最终编写了一个O(n ^ 2)算法,该算法运行正常,但这不能扩展.

        const int numberOfDataPointsInPast = 1000;
        int numberOfDataPoints = 0;
        for (int i = numberOfDataPointsInPast; i >= 0; i--)
        {
            double targetPoint = data[i] * 0.95;
            for (int j = i + numberOfDataPointsInPast; j > i; j--)
            {
                if (data[j] <= targetPoint)
                {
                    numberOfDataPoints++;
                    break;
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

知道怎么把它变成O(n)算法吗?谢谢!

algorithm data-structures

7
推荐指数
1
解决办法
567
查看次数

脚本java:从外部文件导入类

我想导入一个我已经在外部文件夹中编写的类,例如:我的类Example.java位于c:\class\Example.java我的脚本中,就像使用一样

var importedClass = new JavaImporter("c:\\class\\Example.java");
Run Code Online (Sandbox Code Playgroud)

要么

importClass("c:\\class\\Example.java");
Run Code Online (Sandbox Code Playgroud)

这是在ScriptEngine rhino的脚本
中我该怎么做?

java scripting mozilla rhino jdk1.6

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

如何在Visual C++ 9中调试缓冲区溢出?

我有一个用Visual C++ 9编写的巨大的MMC管理单元.每当我在MMC中遇到F5时,mmc.exe崩溃了.如果我附加调试器,我会看到以下消息:

mmc.exe中发生缓冲区溢出,破坏了程序的内部状态.按Break可调试程序或继续终止程序.

有关更多详细信息,请参阅帮助主题"如何调试缓冲区溢出问题".

首先,没有如何调试缓冲区溢出问题任何地方主题.

当我检查调用堆栈时,我发现可能有一些安全cookie用于防止堆栈分配的缓冲区溢出:

MySnapin.dll!__crt_debugger_hook()  Unknown
MySnapin.dll!__report_gsfailure()  Line 315 + 0x7 bytes C
mssvcr90d.dll!ValidateLocalCookies(void (unsigned int)* CookieCheckFunction=0x1014e2e3, _EH4_SCOPETABLE * ScopeTable=0x10493e48, char * FramePointer=0x0007ebf8)  + 0x57 bytes  C
msvcr90d.dll!_except_handler4_common(unsigned int * CookiePointer=0x104bdcc8, void (unsigned int)* CookieCheckFunction=0x1014e2e3, _EXCEPTION_RECORD * ExceptionRecord=0x0007e764, _EXCEPTION_REGISTRATION_RECORD * EstablisherFrame=0x0007ebe8, _CONTEXT * ContextRecord=0x0007e780, void * DispatcherContext=0x0007e738)  + 0x44 bytes    C
MySnapin.dll!_except_handler4(_EXCEPTION_RECORD * ExceptionRecord=0x0007e764, _EXCEPTION_REGISTRATION_RECORD * EstablisherFrame=0x0007ebe8, _CONTEXT * ContextRecord=0x0007e780, void * DispatcherContext=0x0007e738)  + 0x24 bytes C
ntdll.dll!7c9032a8()    
[Frames below may be incorrect and/or missing, …
Run Code Online (Sandbox Code Playgroud)

c++ debugging visual-studio-2008 visual-c++

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

如何以线程安全的方式遍历二叉树?

我需要一种遍历二叉树的方法,使用多个线程并将符合条件的元素存储到列表中.我如何以线程安全的方式做到这一点?

c++ multithreading thread-safety data-structures

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

C中的外部联系

K&R说:

默认情况下,外部变量和函数具有以下属性:所有引用它们的名称相同,即使是单独编译的函数,也是对同一事物的引用

请解释这意味着什么,我不明白

c

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

Android平板电脑的UI设计指南

即将推出的Android平板电脑是否有任何UI设计指南?看起来Archos 7将于本月某个时候上市.我的问题不是支持屏幕大小,而是更多关于为更大的屏幕设备提供更具吸引力的UI界面.

谢谢

android

7
推荐指数
1
解决办法
3813
查看次数

使用Uri或资产中的文件创建MediaPlayer时出错

我将song.mp3复制到我项目的资产目录并编写了这段代码:

private MediaPlayer mp;

Uri uri = Uri.parse("file:///android_asset/song.mp3");

mp=MediaPlayer.create(this, uri);
Run Code Online (Sandbox Code Playgroud)

运行create语句后,变量mp为null.怎么了?

谢谢.

android media-player

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