小编Cha*_*har的帖子

Facebook Like按钮重定向到android中的facebook网站

我正在开发像按钮一样的facebook来集成我的应用程序.这里是从developers.facebook.com复制的html代码

<html>
<body>                   
    <div id="fb-root"></div>
    <script>
        (function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) 
                return;
            js = d.createElement(s); 
            js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=my_app_id";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>
    <fb:like data-href="http://www.facebook.com/facintegra" data-send="true" data-width="450" data-show-faces="false" data-font="tahoma"/>
</body>
Run Code Online (Sandbox Code Playgroud)

我的android活动代码

mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setAppCacheEnabled(true);
    mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    mWebView.loadUrl("file:///android_asset/FacebookLikeView.html");

    m_cObjFacebook = new Facebook("Your_id");

    authorizefacebook();

}

private void authorizefacebook(){
    m_cObjFacebook.authorize(this, m_cPermissions, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            m_cAccessToken = values.getString(Facebook.TOKEN);

        }

        @Override
        public void onFacebookError(FacebookError error) {
            System.out.println(error.toString()); …
Run Code Online (Sandbox Code Playgroud)

android facebook facebook-like

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

Jetpack Compose - 具有可滚动内容的框

我的可组合项如下所示:

fun Screen() {
    Box(modifier = Modifier.fillMaxSize()) {
        Column(
            modifier = Modifier.align(Alignment.TopCenter)
        ) {
            // Content which is pretty large in height (Scrollable)
        }
        Column(
            modifier = Modifier.align(Alignment.BottomCenter)
        ) {
            // A button (CTA for next screen)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

要求是让 CTA 粘在屏幕底部,并且实际内容可以滚动。但是,根据我的实现,如果实际内容的高度变大,则会将 CTA 推离屏幕。

如何让 CTA 粘在屏幕上?

android android-jetpack-compose

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

在android中倾斜显示edittext

我有一个EditText,它通常显示与屏幕X轴平行.我想倾斜地显示它(与横轴成45度左右).是否可以在Android中执行此操作.请指导我一个方向,以便我可以尝试.

在pawelzeiba的答案中得到两个链接之后,我继续解决这个问题,但再次陷入困境,所以我又提出了另一个问题.这是链接.

正如Gunnar Karisson所说,在Android 3.0中引入的View类中有一个setRotation()方法,但我无法使用它,因为我的应用程序应该适用于Android 2.1版本.

所以请帮我解决这个问题.

android android-widget android-edittext

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

带有 MaterialComponents 主题的 ActionBar 背景

我想自定义我的 ActionBar。我的主题如下所示:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@style/ThemeOverlay.MaterialComponents.ActionBar">
    <item name="background">@drawable/actionBarBackground</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在值文件夹中:

<drawable name="actionBarBackground">#FFFFFFFF</drawable>
Run Code Online (Sandbox Code Playgroud)

在 values-night 文件夹中:

<drawable name="actionBarBackground">#FF000000</drawable>
Run Code Online (Sandbox Code Playgroud)

不知道为什么我的 ActionBar 背景颜色没有相应改变。我也尝试以其他不同的方式更改我的主题,但没有任何效果。这是我的其他尝试:

相反actionBarStyle,我使用了actionBarTheme.

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

我也尝试使用colorPrimary.

<item name="colorPrimary">@color/actionBarBackground</item>
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

android android-layout android-actionbar material-components material-components-android

9
推荐指数
3
解决办法
4462
查看次数

Compose Runtime 找不到我的自定义主题

尝试玩弄Jetpack Compose并陷入第一个活动本身。

我的应用程序在启动时崩溃,但出现以下异常:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chanse.locals.cerve.dev, PID: 19105
java.lang.NoSuchMethodError: No static method ChanseTheme(ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Lio/chanse/locals/commonui/theme/ChanseThemeKt; or its super classes (declaration of 'io.chanse.locals.commonui.theme.ChanseThemeKt' appears in /data/app/io.chanse.locals.cerve.dev-E-UJEroB15OQtmBe0WnvGw==/base.apk!classes5.dex)
    at io.chanse.locals.cerve.location.LocationActivity.Screen(LocationActivity.kt:45)
    at io.chanse.locals.cerve.location.LocationActivity$onCreate$1.invoke(LocationActivity.kt:39)
    at io.chanse.locals.cerve.location.LocationActivity$onCreate$1.invoke(LocationActivity.kt:38)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:46)
    at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:333)
    at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:179)
    at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:178)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:46)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
    at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:148)
    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:114)
    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:113)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:46)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
    at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:106)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:162)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:161)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)
    at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:46)
    at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
    at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:161)
    at …
Run Code Online (Sandbox Code Playgroud)

android android-jetpack android-jetpack-compose

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

Modifier.scrollable 不滚动内容

我正在尝试设计一个内容可以滚动的布局。但这不起作用。我在这里做错了什么吗?

@Composable
fun Screen() {
    Box(
        modifier = Modifier
            .padding(16.dp)
            .fillMaxSize()
    ) {
        val offset = remember { mutableStateOf(0f) }
        Column(                                      // This should be scrollable
            modifier = Modifier
                .fillMaxSize()
                .scrollable(
                    orientation = Orientation.Vertical,
                    state = rememberScrollableState { delta ->
                        offset.value = offset.value + delta
                        delta
                    }
                )
        ) {
            Text(...)
            Text(...)
            Spacer(modifier = Modifier.padding(8.dp))
            LazyColumn(...)
            Spacer(modifier = Modifier.padding(8.dp))
            DropdwonMenu(...)
            Text(...)
            Spacer(modifier = Modifier.padding(8.dp))
            Text(...)
            Spacer(modifier = Modifier.padding(8.dp))
            Column(...)
            Spacer(modifier = Modifier.padding(8.dp))
            Button(...)
        }
        Column(
            Modifier
                .fillMaxWidth()
                .align(Alignment.BottomCenter)
        ) { …
Run Code Online (Sandbox Code Playgroud)

android-jetpack-compose

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

Kotlin 在类级别具体化类型

我正在尝试继承枚举的库 API。

abstract class SomeLibraryClass<T> {
    abstract fun test(key: String): T
}

class Item<T : Enum<T>> : SomeLibraryClass<T>() {
    override fun test(key: String): T {
        return enumValueOf(key)
    }
}
Run Code Online (Sandbox Code Playgroud)

无法使 T asreifiedtestas inline。如何继承枚举的库类?

generics kotlin

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

子串中的字符串替换

我想为Java类编写一个方法.该方法接受一串XML数据作为输入,如下所示.

<?xml version="1.0" encoding="UTF-8"?>
<library>

    <book>
        <name> <> Programming in ANSI C <> </name>
        <author> <>  Balaguruswamy <> </author>
        <comment> <> This comment may contain xml entities such as &, < and >. <> </comment>
    </book>

    <book>
        <name> <> A Mathematical Theory of Communication <> </name>
        <author> <> Claude E. Shannon <> </author>
        <comment> <> This comment also may contain xml entities. <> </comment>
    </book>

    <!-- This library contains more than ten thousand books. -->
</library>
Run Code Online (Sandbox Code Playgroud)

XML字符串包含许多以<>开头和结尾的子字符串.子串可以包含XML实体,例如> …

java regex xml

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

LinkedIn按照公司按钮显示空白页面

我通过提供公司名称并单击" 获取代码"按钮来复制此链接中代码.它生成了下面给出的代码

<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/FollowCompany" data-id="361557" data-counter="right"></script>
Run Code Online (Sandbox Code Playgroud)

我将此代码粘贴到html文件的标记中,然后在Chrome,Firefox和IE中运行html文件,但所有浏览器都将空白页面作为输出.

然后我在标签上粘贴那些脚本,但输出保持不变.

我应该如何创建html文件,以便它可以生成inFollow按钮.

请帮我.

html javascript css linkedin

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

Compose Navigation - 导航目的地...不是此 NavGraph 的直接子级

我正在尝试为我的订单管理应用程序构建以下导航:

manage_orders/manage_orders/{locationId}
manage_orders/manage_order_details/{orderId}
Run Code Online (Sandbox Code Playgroud)

这是我的导航代码:

internal sealed class Screen(val route: String) {
    object ManageOrders : Screen(manage_orders)
}

private sealed class LeafScreen(val route: String) {

    fun createRoute(root: Screen): String {
        return "${root.route}/$route"
    }

    object ManageOrders : LeafScreen("manage_orders/{locationId}") {

        fun createRoute(root: Screen, locationId: String): String {
            return "${root.route}/manage_orders/$locationId"
        }
    }

    object ManageOrderDetails : LeafScreen("manage_order_details/{orderId}") {

        fun createRoute(root: Screen, orderId: String): String {
            return "${root.route}/manage_order_details/$orderId"
        }
    }
}

@ExperimentalCoroutinesApi
@Composable
internal fun AppNavigation(
    navController: NavHostController,
    locationId: String,
    modifier: Modifier = Modifier
) {
    NavHost( …
Run Code Online (Sandbox Code Playgroud)

android android-architecture-navigation android-jetpack-compose jetpack-compose-navigation

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