小编Mat*_*ska的帖子

动态设置ViewPager高度

我试图ViewPager用不同的高度放置不同的碎片.我知道这wrap_content不起作用ViewPager所以我试图设置寻呼机高度.我在页面侦听器中设置寻呼机高度:

...
        indicator.setOnPageChangeListener(new OnPageChangeListener() {

            @Override
            public void onPageSelected(int selected) {
                final View view = fragments[selected].getView();
                if (view != null) {
                    pager.setLayoutParams(new LayoutParams(
                            LayoutParams.MATCH_PARENT, view
                                    .getMeasuredHeight()));

                }

            }
Run Code Online (Sandbox Code Playgroud)

不幸的是它没有用,因为getMeasuredHeight()on 返回的值Fragment是错误的.我究竟做错了什么?

android android-fragments android-viewpager

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

Android以编程方式设置扬声器

我试图在服务中以编程方式设置扬声器,audiomanager.setSpeakerphoneOn(true)但似乎它不起作用,我不知道为什么.我应该做别的吗?

谢谢

audio android speakerphone

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

IntentService的StartForeground

我有一个IntentService,我希望通过持续通知使其变得粘稠.问题是通知出现然后立即消失.该服务继续运行.我startForeground()IntentService怎么用?

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);
    Notification notification = new Notification(R.drawable.marker, "Notification service is running",
            System.currentTimeMillis());
    Intent notificationIntent = new Intent(this, DashboardActivity.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
        Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.setLatestEventInfo(this, "App",
            "Notification service is running", pendingIntent);
    notification.flags|=Notification.FLAG_NO_CLEAR;
    startForeground(1337, notification);
    return START_STICKY;
}

@Override
protected void onHandleIntent(Intent intent) {

    String id = intent.getStringExtra(ID);
    WebSocketConnectConfig config = new WebSocketConnectConfig();
    try {
        config.setUrl(new URI("ws://" + App.NET_ADDRESS
                + …
Run Code Online (Sandbox Code Playgroud)

android intentservice foreground-service

12
推荐指数
2
解决办法
8300
查看次数

当我删除Cassandra中的行时,我只删除列而不是行键

如果我使用Cassandra数据库删除ColumnFamily中的每个键remove(key),那么如果我使用get_range_slices,行仍然存在但没有列.我怎么能删除整行?

cassandra nosql delete-row

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

属于Android棒棒糖中不同活动的片段之间的共享元素转换

我在一个属于一个Activity的片段中有一个共享元素.

我想在Android Lollipop中进行共享元素转换,其元素是属于另一个活动的片段的一部分.

可能吗?

我怎样才能做到这一点?

animation android android-animation android-fragments android-5.0-lollipop

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

播放JSON可选变压器

我正在使用Play 2.1 JSON Reads来实现条件转换.

我有一个json对象,我想转换一个可选字段删除\n字符.问题是,如果我从发送的JSON中删除内容,我得到验证错误.

该字段是可选的,我不知道如何描述转换是可选的.这是当前的内容转换:

     val transformContent = (__ \ 'content).json.update(__.read[JsString].map{ 
         value =>
        JsString(value.value.replaceAll("\n", ""))
  })
Run Code Online (Sandbox Code Playgroud)

如何获得可选的字段转换?我应该用Reads.verifyingIf吗?

谢谢

json scala playframework

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

Slick 3会话与回滚

我正在使用光滑3并且我正在尝试使用一些插入执行一些集成测试,一些使用db的代码然后我想在测试结束时回滚所有插入或删除但我找不到任何关于它的文档.

可能吗?我怎样才能实现它?

scala transactions slick

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

如何在Galaxy Nexus等设备上隐藏柔和的触控按钮

我刚刚在Galaxy Nexus上尝试过VLC应用程序.它唯一的问题是Galaxy nexus上的触摸按钮(背面,家庭和menù)并不像Youtube app上那样隐藏.

如何控制触摸按键的行为?

谢谢

android touch uibutton

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

Pinterest就像Android中的Grid一样

我想构建一个类似于Android上的Pinterest应用程序中的网格.

我开始扩展一个AdapterView<ListAdapter>但是我不能做很多工作(例如过度滚动效果)所以,在放弃扩展的想法后AbsListView,现在我开始认为扩展ListView和覆盖layoutChildren()方法更好.

你怎么看?

谢谢

android listview gridview pinterest

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

Google云打印获取访问令牌

我想从我的webServer调用/搜索Google云打印方法.

我正在使用OAuth Web服务器指南获取一个与范围一起使用的refresh_token/access_token:

https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile
Run Code Online (Sandbox Code Playgroud)

然后我打电话给搜索Api,但我获得了403禁止.

    Request DefaultHttpRequest(chunked: false)
    POST /cloudprint/search HTTP/1.1
    Host: www.google.com
    Content-Type: text/plain; charset=utf-8
    Authorization: OAuth yb29.1.AADtN_U9PYyVhGpcS-8MpFhfGVbT4KsZKEoIX2HGePwoNXypjrSwVsS0pGzmaqhktfGBAQ
    Connection: keep-alive
    Accept: */*
    User-Agent: NING/1.0
    Content-Length: 0

    Response DefaultHttpResponse(chunked: true)
    HTTP/1.1 403 Forbidden
    Content-Type: text/html; charset=utf-8
    Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    Pragma: no-cache
    Expires: Fri, 01 Jan 1990 00:00:00 GMT
    Date: Tue, 03 Dec 2013 17:05:09 GMT
    Set-Cookie: NID=67=MQJFdl-YkMdz875n1J2yVNmeUeAvsjVtDGlNvGkNLZdNTHX3YbnStNx9Vg_MiRsmht6hj3XrwJcPJEQeFLlnYKqt2Of1xHJ5HDwNJgOB3svOdnN-JRFcPxYt4AU10eSM;Domain=.google.com;Path=/;Expires=Wed, 04-Jun-2014 17:05:09 GMT;HttpOnly
    P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: …
Run Code Online (Sandbox Code Playgroud)

oauth-2.0 google-cloud-print google-oauth

8
推荐指数
2
解决办法
3851
查看次数