小编can*_*ova的帖子

以编程方式设置TextView的布局权重

我正在尝试动态创建TableRow对象并将其添加到TableLayout.该TableRow对象有2个项目,一个TextViewCheckBox.该TextView项目需要有自己的布局权重设置为1,以推动CheckBox项目的最右边.

我找不到有关如何以编程方式设置项目的布局权重的文档TextView.

layout android textview android-layout-weight

207
推荐指数
9
解决办法
22万
查看次数

双窗格首选项屏幕的问题

问题
将设备从单窗格纵向旋转PreferenceScreen到双窗格环境PreferenceScreen,导致横向仅显示为单窗格.查看标题屏幕时不会发生.

设置
仅适用于ICS及以上版本.我有一个PreferenceActivity负载preference-headers.每个标题链接一个Fragment,然后加载一个PreferenceScreen.相当运行的mil.

细节
一切运作良好,直到我注意到Android只会自动切换到某个屏幕的双窗格外观.经过一些研究,我从一篇Commonsware帖子中了解到,Android只会针对sw720dp这样做.如果你问我我有点浪费,因为许多设备def有足够的空间用于双窗格.所以我重写了onIsMultiPane()为w600dp和up返回true 的方法.工作就像一个魅力......有点儿.

给定一个设备,将在纵向和双窗格中显示单窗格; 以纵向查看标题并旋转到横向,工作正常.但是,如果选择一个标题并以纵向模式加载它的后续屏幕,则旋转到横向设备将保持单窗格而不是切换回双窗格.如果您然后返回导航到标题屏幕,它将返回双窗格外观,但它不会预先选择标题.因此,详细窗格保持空白.

这是预期的行为吗?无论如何要解决它吗?我也试过覆盖onIsHidingHeaders(),但这只会导致一切都显示为空白.

代码
偏好活动:

public class SettingsActivity extends PreferenceActivity {
@Override
public void onBuildHeaders(List<Header> target) {
    super.onBuildHeaders(target);
    loadHeadersFromResource(R.xml.preference, target);
}

@Override
public boolean onIsMultiPane() {
    return getResources().getBoolean(R.bool.pref_prefer_dual_pane);
}
}
Run Code Online (Sandbox Code Playgroud)


首选项标题片段:

public class ExpansionsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_expansions);
}

public static ExpansionsFragment newInstance() {
    ExpansionsFragment frag = new …
Run Code Online (Sandbox Code Playgroud)

java android preferenceactivity android-preferences android-fragments

36
推荐指数
1
解决办法
2181
查看次数

访问sim工具包的android应用程序

我想构建一个访问来自sim工具包的信息的应用程序.我的运营商允许您访问诸如查看帐户余额,发送和接收现金以及大量服务等服务.是否有任何资源,教程甚至只是指示我如何访问SIM工具包中的信息.

android sim-toolkit android-service

23
推荐指数
1
解决办法
3859
查看次数

Android phonegap项目垃圾邮件QTAGUID消息

我一直有这个问题已经有一段时间了,虽然它不会对我的应用程序产生负面影响,但如果可以,我想解决它.我不确定如何描述问题.

基本上,我有一个Android PhoneGap 1.9项目,使用API​​ 15(这也发生在API 10下),LogCat日志有来自QTAGUID的无情垃圾邮件,特别是来自我的应用程序.

08-04 14:31:30.092: I/qtaguid(15542): Failed write_ctrl(u 118) res=-1 errno=22
08-04 14:31:30.092: I/qtaguid(15542): Untagging socket 118 failed errno=-22
08-04 14:31:30.092: I/qtaguid(15542): Failed write_ctrl(u 123) res=-1 errno=22
08-04 14:31:30.092: I/qtaguid(15542): Untagging socket 123 failed errno=-22
08-04 14:31:36.338: I/qtaguid(15542): Failed write_ctrl(u 116) res=-1 errno=22
08-04 14:31:36.338: I/qtaguid(15542): Untagging socket 116 failed errno=-22
08-04 14:31:36.368: I/qtaguid(15542): Failed write_ctrl(t 116 43082816946176 1074812240) res=-1 errno=1
08-04 14:31:36.368: I/qtaguid(15542): Tagging socket 116 with tag 272f00000000(10031) for …
Run Code Online (Sandbox Code Playgroud)

android jquery-mobile phonegap-plugins cordova

16
推荐指数
1
解决办法
3186
查看次数

每隔几秒钟收到一次TIMEZONE_CHANGED意图

我使用带有TIMEZONE_CHANGED操作的BroadcastReceiver来使用AlarmManager重置警报,以确保警报在设定的时间运行,而不是提前几小时或更晚,具体取决于时区的变化.

然而,在用户发送的最新日志中,我看到有关每隔几秒钟收到TIMEZONE_CHANGED操作的意图的信息,用户抱怨应用程序出现故障.

这是我的BroadcastReceiver的onReceive代码

@Override
public void onReceive(Context context, Intent intent) {
    Utils.log("OnTimeChange");
    String action = intent.getAction();

    if (action.equals(Intent.ACTION_TIME_CHANGED)) {
        Utils.log("TimeChange");
    } else if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)) {
        Utils.log("TimeZoneChanged");
    }
    BroadcastsManager.updateBroadcastsFromAlarms(context,
            AlarmsDbAdapter.getInstance(context));
}
Run Code Online (Sandbox Code Playgroud)

清单的意图过滤器:

<intent-filter>
    <action android:name="android.intent.action.TIMEZONE_CHANGED" />
    <action android:name="android.intent.action.TIME_SET" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

和日志的一部分(它是这样的超过一个小时 - 日志的全长)

1. 19/4 7:41:54 - posting alarm 3 for 8:15 (in 0h)
2. 19/4 7:44:29 - OnTimeChange
3. 19/4 7:44:29 - TimeZoneChanged
4. 19/4 7:44:29 - posting alarm 3 for 8:15 (in 0h)
5. 19/4 7:44:54 - OnTimeChange
6. …
Run Code Online (Sandbox Code Playgroud)

timezone android broadcastreceiver alarmmanager android-intent

10
推荐指数
1
解决办法
6018
查看次数

Android 4.x RemoteControlClient.setTransportControlFlags()不起作用?

我正在尝试使用RemoteControlClient类来支持我的应用程序的锁屏播放器.一个问题是设置传输控制标志似乎无法正常工作.

例如,我试图只显示播放/停止图标没有上一个/下一个:

mRemoteControlClient.setTransportControlFlags(
                        RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
                        RemoteControlClient.FLAG_KEY_MEDIA_STOP);
Run Code Online (Sandbox Code Playgroud)

这显示了之前的图标和暂停图标!为什么?

为了使事情更糟按下停止/播放按钮时,你只收到KEYCODE_MEDIA_PLAY_PAUSE时,你应该得到KEYCODE_MEDIA_STOPKEYCODE_MEDIA_PLAY.

如果我发现我正确地做到这一点,这在Android方面是令人沮丧的糟糕发展.

android remote-control android-remoteview

9
推荐指数
1
解决办法
1308
查看次数

setShadowLayer会导致GridView中的绘制时间变慢?

我目前正在使用包含ImageViews的GridView,并希望我的图像背后有阴影.例如,在网格中可能有15个图像随时可见.在假设我希望我的屏幕以50fps渲染以显得平滑的情况下工作,我的数学表明我希望每个ImageView的总绘制时间不会差于大约1.3ms.

我看了一下Romain Guy如何在他的Shelves应用程序中做阴影:http: //code.google.com/p/shelves/source/browse/trunk/Shelves/src/org/curiouscreature/android/shelves/util/ ImageUtilities.java

这似乎有道理,所以我创建了以下类:

 public class ShadowImageView extends ImageView {
     private static final int SHADOW_RADIUS = 8;
     private static final int SHADOW_COLOR = 0x99000000;
     private static final Paint SHADOW_PAINT = new Paint();

     static {
         SHADOW_PAINT.setShadowLayer(SHADOW_RADIUS / 2.0f, 0.0f, 
             0.0f, SHADOW_COLOR);
         SHADOW_PAINT.setColor(0xFF000000);
         SHADOW_PAINT.setStyle(Paint.Style.FILL);
     }

     public ShadowImageView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }

     @Override
     public void onDraw(Canvas canvas) {
         final int containerWidth = getMeasuredWidth();
         final int containerHeight = getMeasuredHeight();

         canvas.drawRect(
                 SHADOW_RADIUS / 2.0f,
                 SHADOW_RADIUS / 2.0f,
                 containerWidth …
Run Code Online (Sandbox Code Playgroud)

android android-ui android-listview android-imageview android-gridview

6
推荐指数
0
解决办法
1818
查看次数

Android发送带附件的电子邮件并不总是有效

我正在使用ContentProvider发送包含附件的电子邮件.

  1. 首先,我将文件写入缓存目录.
  2. 然后,我创建一个电子邮件,其中包含内容提供商可以找到的每个文件的URL
  3. 然后我用ACTION_SEND_MULTIPLE意图开始一个新活动.
  4. 我选择gmail然后点击发送按钮.

这有时会起作用,它似乎在一段时间内第一次起作用,但在后续尝试之后不起作用......但它并不总是那样.

当它不起作用时,电子邮件停留在gmail中发送.这发生在2.3.3和4.0.1上,在gmail客户端打开邮件并点击发送按钮,因此经常导致消息几乎立即发送,但不是每次都发送.

使用Google云端硬盘打开Intent与gmail具有相同的行为.

到目前为止,使用内置的Exchange邮件客户端打开Intent始终有效.

以下是发送电子邮件的代码:

            Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            sendIntent.putExtra(Intent.EXTRA_EMAIL, exportParams.emailAddresses);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Leader Activity Report");
            sendIntent.putExtra(Intent.EXTRA_TEXT, "Leader Activity Report, see attached file.");
            Uri fileUri = CachedFileProvider.createFileUri(result.fileName);
            if (L.dbg())
                L.dbg("Using uri:" + fileUri.toString());
            ArrayList<Uri> uris = new ArrayList<Uri>();
            uris.add(fileUri);
            Uri fileUri2 = CachedFileProvider.createFileUri(result.fileNameDayByDay);
            uris.add(fileUri2);
            if (L.dbg())
                L.dbg("Using uri2:" + fileUri2.toString());
            sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            sendIntent.setType("text/plain");
            parent.startActivity(sendIntent);
Run Code Online (Sandbox Code Playgroud)

这是内容提供商

public class CachedFileProvider extends ContentProvider {

private static final String CLASS_NAME = "CachedFileProvider";
public static final String AUTHORITY = "com.josh.lll.file.provider"; …
Run Code Online (Sandbox Code Playgroud)

gmail android android-intent android-contentprovider

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

如何将Imageview置于其他布局之后

我正在使用imageview进行动画制作,使其看起来像是从左到右的动作.但我的图像显示在其他视图的前面,以便用户可以单击图像.我试图在另一个视图后面显示它.

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

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >

     <Button
         android:id="@+id/languageChangePopup"
         style="?android:attr/buttonStyleSmall"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginBottom="10dp"
         android:layout_marginLeft="50dp"
         android:background="@drawable/startbtn" />

    <EditText
        android:id="@+id/showOutputEdit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="110dp"
        android:layout_marginTop="50dp"
        android:background="@drawable/display_textbx"
        android:cursorVisible="false"
        android:gravity="right|center"
        android:paddingLeft="70dp"
        android:paddingRight="70dp"
        android:textColor="#ffffff"
        android:textSize="45sp"
        android:textStyle="bold" />

    </LinearLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent" android:layout_weight="3.49">

        <TableLayout
            android:id="@+id/tableLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="136dp"
            android:layout_marginTop="19dp" >

            <TableRow
                android:id="@+id/tableRow5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                 >

                <Button
                    android:id="@+id/clearBtn"
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@string/cbtn" />

                <Button
                    android:id="@+id/sevenBtn"
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@string/sevenbtn" />

                <Button
                    android:id="@+id/eightBtn"
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@string/eightbtn" /> …
Run Code Online (Sandbox Code Playgroud)

android relativelayout android-layout

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

Android studio - 无效的App-Engine SDK路径

我试图在Android工作室中运行我的第一个Android应用程序.应用程序使用新项目vizard成功创建但无法运行,因为收到此错误 -

无效的App-Engine SDK路径

请帮忙

google-app-engine android android-studio

6
推荐指数
3
解决办法
6672
查看次数