小编Phi*_*ais的帖子

使用 TextInputLayout.OutlinedBox 样式的 Material Design Spinner

我目前正在使用 Material Design TextInputLayout OutlinedBox,如下所示:

        <android.support.design.widget.TextInputLayout
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/myEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Title"
                android:inputType="text"/>

        </android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

我正在尝试Spinner在 TextInputEditText 下添加一个下拉框,并希望保持相同的样式:OutlinedBox。

我看到 Material Design, Material Design Text Fields似乎支持下拉菜单。如此处所示的区域:

如此处所示的区域

我目前正在使用 Spinner 生成下拉菜单。

        <Spinner
            style="@style/Widget.AppCompat.Spinner.DropDown"
            android:id="@+id/option"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:dropDownWidth="match_parent" />
Run Code Online (Sandbox Code Playgroud)

似乎不可能按照 OutlinedBox 设计添加下拉菜单。是否有一个库可以让我实现这一点,或者是否有更好的方法在 Material Design 中实现这一点?

android material-design android-textinputlayout material-components material-components-android

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

实现iAd获取ERROR后:无法从DB获取接收方数据

我在一个全新的项目中实现了一个非常简单的iAd横幅,当我运行它时,我收到错误ERROR:无法从数据库中获取接收器数据!

代码是非常基本的,所以我不认为问题与代码有关,但我会添加它以防万一:

#import <iAd/iAd.h>

@interface MainViewController : UIViewController <ADBannerViewDelegate>
{ADBannerView *adView;}
@property (retain, nonatomic) IBOutlet ADBannerView *adView;

@end

@implementation MainViewController
@synthesize adView;

- (void)viewDidLoad
{
    [super viewDidLoad];
    adView.delegate = self;
    [adView setHidden:YES];
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
    [adView setHidden:NO];
    NSLog(@"is laoding");
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
    [adView setHidden:YES];
    NSLog(@"is NOT loading");
}

@end
Run Code Online (Sandbox Code Playgroud)

其他人收到此错误?对此事有何帮助?

iad ios7

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

将Java转换为Kotlin错误的Android Studio无法推断此参数的类型.请明确说明

我是Android开发的新手(6个月前开始),并希望从Java迁移到Kotlin.我已将我的项目转换为Kotlin并修复了所有问题,但我无法弄清楚如何修复它.

我正在尝试检索JSONArray(如类JsonManager中所示)并通过方法调用在名为DataDisplayPage的第二个类中使用检索到的数据.

我收到以下控制台错误,这些错误发生在第二类的这一行:jManager.fetch_data{ theJsonArray ->.

无法推断此参数的类型.请明确说明.

类型不匹配:推断类型是(???) - > Unit但是预期OnTaskCompleted

第一类JsonManager

interface OnTaskCompleted {
    fun onTaskCompleted(theJsonArray: JSONArray)
}

class JsonManager {
    var listener: OnTaskCompleted? = null

    init {
        Log.d("JsonManager", "Instance created")
    }

    fun fetch_data(callback : OnTaskCompleted) {
        listener = callback
         val url ="https://someURL"

        AndroidNetworking.get(url)
            .build()
            .getAsJSONArray(object : JSONArrayRequestListener {
                override fun onResponse(response: JSONArray) {
                    listener?.onTaskCompleted(response)
                }

                override fun onError(anError: ANError) {
                    Log.d("error", anError.toString())
                }
            })

}
Run Code Online (Sandbox Code Playgroud)

第二类DataDisplayPage

class DataDisplayPage : AppCompatActivity()

    fun onStartUp() {

        val jManager = JsonManager() …
Run Code Online (Sandbox Code Playgroud)

android kotlin

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

Exoplayer for android,尝试流式传输 m3u8 文件并收到错误:所有可用的提取器都无法读取流

我正在尝试流式传输 m3u8 文件,但出现错误。我使用的网址如下:http : //storage.googleapis.com/videos.siku.org/10005/dash/master.m3u8 这个流媒体视频在浏览器中可以正常工作。我在运行时收到以下错误:

ExoPlayerImplInternal:源错误。com.google.android.exoplayer2.source.UnrecognizedInputFormatException: 没有可用的提取器 (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsavrExtractor, WlacExtractor, PsavrExtractor, PsavrExtractor . 在 com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractorHolder.selectExtractor(ProgressiveMediaPeriod.java:1090) 在 com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:969) 在 com。 .android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 在 java.util。

我正在使用ExoPlayerHelper类(它取自 stackoverflow 问题,虽然我确实按照推荐的方式实现了这个,但我遇到了同样的错误)

这是我正在使用的课程:

class ExoPlayerHelper(
    private val playerView: PlayerView,
    onError: (ExoPlaybackException) -> Unit,
    onPlayerBuffer: (Boolean) -> Unit
) {
    private var exoPlayer: ExoPlayer? = null
    private var mediaSource: ProgressiveMediaSource? = null
    private val playerListener = object : Player.EventListener {
        override fun onPlayerError(error: ExoPlaybackException) …
Run Code Online (Sandbox Code Playgroud)

android video-streaming exoplayer2.x

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

Android 安装时资产交付访问

我正在使用该选项将我的 Android 应用程序配置为使用Play Asset Deliveryinstall-time我正在遵循此处找到的官方指南

这是我的以下配置:

在项目设置中,我创建了一个 asset_pack 目录,包括子目录 src/main/assets

在应用程序 gradle 中,我设置了我的资源包:

assetPacks = [":asset_pack"]
Run Code Online (Sandbox Code Playgroud)

在 settings.gradle 中,我包含了我的资源包:

include ':app'
include ':asset_pack'
Run Code Online (Sandbox Code Playgroud)

在资产包gradle中,我添加了对资产包的引用和下载方法:

assetPack {
    packName = "asset_pack"
    dynamicDelivery {
        deliveryType = "install-time"
    }
}
Run Code Online (Sandbox Code Playgroud)

一切似乎都工作正常,直到我尝试从这个根级别目录检索资产。

该文档指出我应该使用这种方法:

val packageContext: Context = createPackageContext("com.example.app", 0)
val assetManager: AssetManager = packageContext.assets
val inputStream: InputStream = assetManager.open("basemap/phil.jpg")
Run Code Online (Sandbox Code Playgroud)

我的应用程序在尝试检索资产时崩溃(我已将 com.example.app 替换为我的应用程序信息)

当我查找 a​​ssetManager 列表时,assetManager.list("")显示的文件都是应用程序包的一部分。不幸的是,名为 asset_pack 的文件夹或其任何内容都不会显示为选项。

这是我的问题:我想我看不到 asset_pack 文件的原因是因为它与我的应用程序目录处于同一级别,但我不知道如何使用 assetManager 访问该文件夹。有人知道我如何访问这些文件吗?

android android-assets kotlin android-asset-delivery

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

当“添加语言”部分中不存在语言时,Android 运行时语言更改不起作用

我正在尝试使用以下代码在本地更改我的应用程序语言。如果手机设置的添加语言中有英语和法语,然后进入我的应用更改语言,则语言更改成功,但如果我从手机设置的添加语言中删除语言,则改变不起作用。从我在网上看到的示例来看,应该可以更改它,而无需在手机设置的“添加语言”中添加任何其他语言。我不确定我做错了什么,有没有一种方法可以启用语言更改,而无需在手机设置中添加语言?

任何指向某些文档的链接也将非常感激。

这是我创建的用于启用语言切换的 LocalUtil 对象:

object LocalUtil {

    fun applyLanguageContext(context: Context, locale: Locale?): Context {

        if (locale == null) return context
        if (locale == getLocale(context.resources.configuration)) return context
        return try {
            setupLocale(locale)
            val resources = context.resources
            val configuration = getOverridingConfig(locale, resources)
            updateResources(context, resources, configuration)
            context.createConfigurationContext(configuration)
        } catch (e: Exception) {
            e.printStackTrace()
            context
        }
    }

    private fun updateResources(
        context: Context,
        resources: Resources,
        config: Configuration
    ) {
        if (context.applicationContext !== context) {
            resources.updateConfiguration(config, resources.displayMetrics)
        }
    }

    private …
Run Code Online (Sandbox Code Playgroud)

android localization internationalization kotlin

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

Xcode AMSlideMenu 仅使用按钮打开左侧菜单,禁用滑动

这听起来像是一个奇怪的请求,但我一直在使用 AMSlideMenu(这很棒)https://github.com/SocialObjects-Software/AMSlideMenu

但是在我的一个特定项目中,我只需要使用一个按钮就可以打开左侧菜单。

现在我有一个按钮可以打开和关闭菜单,但是对于这个特定的项目,我需要使用滑动手势,所以我需要禁用通过滑动访问菜单。

我一直在查看 AMSlideMenu 文件中的方法,但我不知道如何禁用滑动。

任何帮助将不胜感激!

objective-c ios xcode5 amslidemenu

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

如何在 Kotlin 的 Retrofit @GET 请求中添加 URL 参数

我目前正在尝试使用 Kotlin 中的 Retrofit 从服务器获取 JSONArray。这是我正在使用的界面:

interface TripsService {

    @GET("/coordsOfTrip{id}")
    fun getTripCoord(
            @Header("Authorization") token: String,
            @Query("id") id: Int
            ): Deferred<JSONArray>

    companion object{
        operator fun invoke(
            connectivityInterceptor: ConnectivityInterceptor
        ):TripsService{
            val okHttpClient = OkHttpClient.Builder().addInterceptor(connectivityInterceptor).build()
            return Retrofit.Builder()
                .client(okHttpClient)
                .baseUrl("https://someurl.com/")
                .addCallAdapterFactory(CoroutineCallAdapterFactory())
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(TripsService::class.java)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

所需的网址是: https://someurl.com/coordsOfTrip?id=201

我收到以下错误消息:

retrofit2.HttpException:不允许使用 HTTP 405 方法

我知道 URL 有效,因为我可以通过浏览器访问它。

有人可以帮我确定我做错了什么吗?

android kotlin retrofit retrofit2

0
推荐指数
1
解决办法
3901
查看次数