小编mad*_*mad的帖子

如何在objective-c中编写一个函数,我可以使用我的iPhone应用程序中的任何对象?

我想创建一个传递对象的函数.然后,此功能应该为我打印一些信息.

喜欢:

analyzeThis(anyObject);
Run Code Online (Sandbox Code Playgroud)

我知道方法,但不了解如何制作功能.据我所知,一个函数在所有方法和类中都是全局的,对吗?

iphone function objective-c

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

在 UIButton/UITableViewCell/UICollectionViewCell 选择上禁用 VoiceOver

打开 VoiceOver 后,当焦点位于UIButton/ UITableViewCell/ 上时UICollectionViewCell,VoiceOver 会读取它的辅助功能标签一次。

然后,只要用户双击以选择UIButton/ UITableViewCell/ UICollectionViewCell,VoiceOver 除了在UIButton/ UITableViewCell/UICollectionViewCell选择上执行操作(导航等)外,还会再次读取相同的辅助功能标签。

我搜索了很多,但没能找到一种方法,停止/禁用VoiceOver会读无障碍的标签UIButton/ UITableViewCell/UICollectionViewCell选择。

任何帮助将不胜感激。

accessibility ios voiceover

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

UiAutomator-将小部件添加到主屏幕

我在Google的uiautomator方面拥有丰富的经验;但是,在将小部件添加到手机主屏幕时,我似乎很沮丧。现在,让它保持简单,并假设要添加小部件的屏幕为空。考虑的过程将是打开应用程序抽屉>单击窗口小部件选项卡>找到要添加的窗口小部件>长按并将窗口小部件拖动到主屏幕。似乎小部件不是“长期可点击的”。任何想法/建议/解决方案将不胜感激。我实现的代码如下。

@Override
protected void setUp() throws UiObjectNotFoundException {
    getUiDevice().pressHome();

    new UiObject(new UiSelector().className(TEXT_VIEW).description("Apps")).clickAndWaitForNewWindow();
    new UiObject(new UiSelector().className(TEXT_VIEW).text("Widgets")).click();

    UiScrollable widgets = new UiScrollable(new UiSelector().scrollable(true));
    widgets.setAsHorizontalList();
    widgets.flingToEnd(MAX_SWIPES);

    UiObject widget = widgets.getChildByText(
            new UiSelector().className(TEXT_VIEW).resourceId("com.android.launcher:id/widget_name"),
            WIDGET_NAME
    );

    // Returns true
    System.out.println("exists(): " + widget.exists());
    // Returns false...
    System.out.println("longClickable(): " + widget.isLongClickable());

    widget.longClick();

    // Also tried...
    int startX = sonosWidget.getVisibleBounds().centerX();
    int startY = sonosWidget.getVisibleBounds().centerY();
    getUiDevice().drag(startX, startY, 0, 0, 3);
}
Run Code Online (Sandbox Code Playgroud)

automation android android-uiautomator

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

Android 中具有网络连接的 App Widget

我正在尝试使用网络数据开发一个AppWidget。到目前为止,我有一个应用程序(已启动并正在运行),其中包含自定义AsyncTaskLoader(获取 URL 并提供解析数据)到我的片段内的加载器。没有缓存或数据库来保存该数据。如果可能的话,我的最佳实践是使用一些现有的网络+解析类功能。

通过搜索许多示例和教程,我要么找到了简单的离线小部件,要么找到了其他带有内容提供者和观察者的小部件。他们都不使用网络连接。

  1. 我可以有一个从在线 json 而不是内容解析器/提供者获取数据的小部件吗?任何这样的例子或指南都会非常有帮助!

  2. 我的应用程序支持2.0及以上版本。根据我的研究,我发现我必须实现 2 个 Android 3+ 及更低版本的小部件。有没有其他更简单的方法来避免双重编码?

提前致谢!

android android-appwidget

5
推荐指数
0
解决办法
556
查看次数

AppCompatDialog 与 DialogFragment

具有最新的 AppCompat

compile "com.android.support:appcompat-v7:22.2.1"
Run Code Online (Sandbox Code Playgroud)

两者都可用AppCompatDialogDialogFragment我应该选择哪一种?是否存在我可以避免的差异或问题?

编辑:

我尝试通过转换现有的现有版本来使用AppCompatDialog或,但似乎都不起作用。DialogFragmentDialoggetDialog().setTitle("Title")

android dialog android-appcompat android-dialogfragment

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

PreferenceFragmentCompat在初始化时崩溃

我已经用ViewPager制作了一个应用程序。当我进行调试构建并在手机上对其进行测试时,一切工作正常。(不是模拟器)但是,当我构建发行版.apk并安装它时,PreferenceFragmentCompat的addPreferencesFromResource(R.xml.preferences); 使应用程序崩溃。 PreferenceFragmentCompat-Android开发人员

ApplicationSettingsFragment.java:

package hu.t_bond.homecontroller.Fragments;

import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;

import hu.t_bond.homecontroller.Launcher;
import hu.t_bond.homecontroller.R;

public class ApplicationSettingsFragment extends PreferenceFragmentCompat {

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

        getPreferenceManager().setSharedPreferencesName(Launcher.SETTINGS_NAME);

        addPreferencesFromResource(R.xml.preferences);
    }

    @Override
    public void onCreatePreferences(Bundle bundle, String s)
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

res / xml / preferences.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <CheckBoxPreference
        android:key="AutoUpdatesEnabled"
        android:title="@string/auto_updates_enabled"
        android:summary="@string/auto_updates_enabled_description"
        android:defaultValue="true" />
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)

和崩溃报告:

10-26 14:20:07.661 17763-17890/? E/AndroidRuntime: FATAL EXCEPTION: main
 Process: hu.t_bond.homecontroller, PID: 17763
 android.view.InflateException: Binary XML file line #2: Error inflating class PreferenceScreen …
Run Code Online (Sandbox Code Playgroud)

android android-support-library preferencefragment preference-v7

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

列表视图下方的页脚固定在屏幕底部

我试图在我的列表视图下面有一个页脚.

这是怎么做的.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:divider="#BE6D79"
    android:dividerHeight="3dp" />

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="30dp"
    android:background="@color/darkDetna"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/contactBtn"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_weight="1"
        android:background="@drawable/listselector"
        android:paddingRight="0dip"
        android:text="Contact" />

    <Button
        android:id="@+id/faq"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_weight="1"
        android:background="@drawable/listselector"
        android:padding="0dip"
        android:text="Terms And Conditions" />

    <Button
        android:id="@+id/feedback"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_weight="1"
        android:background="@drawable/listselector"
        android:padding="0dip"
        android:text="Feedback  " />

    <Button
        android:id="@+id/fullSIte"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_weight="1"
        android:background="@drawable/listselector"
        android:padding="0dip"
        android:text="Full Site" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这里

但问题是列表内容很小,或者页脚视图下方只有一个列表项.

我希望页脚固定在屏幕的底部.

在此先感谢您的时间和帮助.

android listview android-layout android-listview

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

Android获取数据库列的总和

我需要帮助总结我的数据库中的一列(金额)中的所有值.我可以得到一个特定的价值.但是我需要一个特定列的总和,有人告诉我我做错了什么

这是我的代码

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new OnClickListener() {          
       public void onClick(View v) {                
          DatabaseAdapter databaseAdapter = new DatabaseAdapter(getApplicationContext());
          databaseAdapter.open();
          ArrayList<String> records = databaseAdapter.fetchAllRecords();
          if (records.size() > 0) {
              et.setText(records.get(0));
          }
          databaseAdapter.close();
      }
   });

    //Create our database by opening it and closing it
    DatabaseAdapter databaseAdapter = new DatabaseAdapter(getApplicationContext());
    databaseAdapter.open();
    databaseAdapter.close();
} 

private Object append(CharSequence text) {
    // TODO Auto-generated method stub
    return null;
}

/** Create a new dialog for date picker */
@Override
protected Dialog onCreateDialog(int id) { …
Run Code Online (Sandbox Code Playgroud)

sqlite android

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

应用程序未从 Xcode 运行时会自动关闭

我正在使用 React Native 开发一个应用程序。

当我在通过 USB 连接的 iOS 设备上测试它时(当我从 Xcode 集成开发环境运行时)。它按预期工作。但如果我拔掉 USB 线,该应用程序仍在手机上,可以打开,但只显示“NameofTheApp - Powered by React Native”,并在 10 秒后自动关闭。

我有以下问题

  • 仅在开发模式下正常吗
  • 这是我在发布应用程序之前必须修复的错误吗?

ios react-native

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

使用@ style/PreferenceThemeOverlay的PreferenceFragmentCompat填充问题

在使用preference-v7支持库(版本23.1.0)中的默认PreferenceThemeOverlay时,我遇到了以下问题.从API 22开始,我的PreferenceFragmentCompat在我的首选项列表的左侧和右侧添加了一个丑陋的附加填充.

的build.gradle:

compile 'com.android.support:appcompat-v7:23.1.0'
Run Code Online (Sandbox Code Playgroud)

styles.xml:

<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我没有在stackoverflow上找到任何有用的解决方案后,我自己写了一个解决方法.我只是想与你们分享.

android android-support-library preferencefragment preference-v7

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