小编XII*_*-th的帖子

Android中的多行TextView?

我确实喜欢下面的内容 xml

<TableRow>
    <TextView android:id="@+id/address1"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:gravity="left"
        android:maxLines="4" 
        android:singleLine="false"              
        android:text="Johar Mor, Gulistan-e-Johar, Karachi" >
    </TextView> 
</TableRow>
Run Code Online (Sandbox Code Playgroud)

它不起作用multiline,我正在使用TableLayout......

那我在这做什么错呢?

android multiline tablelayout textview

142
推荐指数
8
解决办法
28万
查看次数

从adb向BroadcastReceiver发送意图

我有BroadcastReceiver类:

public class IntentReceiver extends BroadcastReceiver {

    final String tag = "Intent Intercepter";

    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            String data = intent.getStringExtra("sms_body");
            Log.i(tag, data);
            Toast.makeText(context, data.subSequence(0, data.length()), Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            Toast.makeText(context, "Intercepted", Toast.LENGTH_LONG).show();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

而且在清单中:

<receiver android:name="com.whereismywifeserver.IntentReceiver" android:enabled="true">
    <intent-filter android:priority="999">
        <action android:name="com.whereismywifeserver.intent.TEST"/>
    </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试从adb发送意图时,我收到错误:

C:\Users\i.yesilevsky>adb shell am start -a com.whereismywifeserver.intent.TEST
--es sms_body "test from adb" -c android.intent.category.HOME -n  com.whereismywifeserver/.IntentReceiver
Starting: Intent { act=com.whereismywifeserver.intent.TEST t=[android.intent.category.HOME] cmp=com.whereismywifeserver/.IntentReceiver (has extras) }
Error …
Run Code Online (Sandbox Code Playgroud)

android adb broadcastreceiver android-intent

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

尝试使用Java中的多个Resource

我是新手Java8,我想知道,对于AutoCloseable资源,我是否必须try为每个添加一个resource,或者它将使用上面的代码

try (Connection conn = getConnection();) {

            Statement stmt = conn.createStatement();

            ResultSet rset = stmt.executeQuery(sql);

            while (rset.next()) {
                TelefonicaDataVO vo = new TelefonicaDataVO();
                vo.setTelefonicaDataId(rset.getString("Telefonica_PSD_ID"));
                vo.setReceptionDate(nvl(rset.getTimestamp("CREATION_DATE")));
                vo.setMessage(nvl(rset.getString("MESSAGE")));
                ret.add(vo);
            }
        }
Run Code Online (Sandbox Code Playgroud)

java try-with-resources autocloseable

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

无法解析com.android.billingclient:billing:dp-1

project(":android") {
apply plugin: "android"
apply plugin: "com.android.application"

configurations { natives }

dependencies {
    compile project(":core")
    compile "com.android.billingclient:billing:dp-1"
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
    compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
    compile "com.google.android.gms:play-services-ads:11.0.0"
    compile "com.android.billingclient:billing:dp-1"


}
Run Code Online (Sandbox Code Playgroud)

}

我在我的android工作室项目中有以下gradle代码,它仍然给我一个错误"无法解决com.android.billingclient:billing:dp-1",为什么它不会同步?我应该附加更多的东西吗?

android gradle android-studio

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

日志 spring Bean 实例化

我们如何在 Spring 中记录每个 bean 实例化?

  • 我希望每次初始化 bean 时都记录一条消息。
  • 我有 N 个 bean,我不想在每个 bean 的 init 方法上放置任何记录器。
  • 我认为这是一个跨领域的问题,但不确定如何实现这一点。

有没有办法。?

java spring

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

如何在没有 ActionBar 的 AndroidX 中设置 BottomNavigationView

我在 Android 上使用具有单活动模式的 Android 架构组件。我使用的导航模式是 BottomNavigationView。我实际上希望父活动没有 ActionBar,但将我的主题设置为 NoActionBar 类型会使应用程序崩溃。在 Activity 中设置导航已完成,如下所示

val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
    setOf(R.id.navigation_popular, R.id.navigation_top_rated, R.id.navigation_favorites)
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
Run Code Online (Sandbox Code Playgroud)

由于我希望拥有一些带有 ActionBar 的片段(例如 CollapsingToolbarLayout),因此如何设置底部导航以没有 actionBar?

android android-fragments android-actionbar bottomnavigationview android-architecture-components

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

Cassandra:找不到命令

我目前正在研究有关数据建模的Cassandra教程。我不明白为什么每次尝试从bin文件夹运行cassandra服务时都会收到错误消息:

“卡桑德拉:找不到命令”。

如果尝试运行nodetool或cqlsh实用程序,也会发生相同的情况。有人可以帮助我解决问题吗?

cassandra nodetool cqlsh datastax

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

导航架构组件 - 登录屏幕

我打算像这样实现导航:
在此输入图像描述
我面临的问题是当用户进入LoginFragmennt并按下后退按钮时,它再次加载LognFragment即.卡在循环中.

LoginnFragment按照这个答案导航到使用条件导航.

如何正确实现这个?

java android kotlin android-architecture-navigation

5
推荐指数
3
解决办法
2005
查看次数

如何在 Material Design 3 中使用不透明度的主题标记

在主题的迁移过程中,我坚持使用 Material Design 3 中的不透明度标记。我在androidx.compose.material3中没有找到任何标记。

我正在寻找类似于下面的构造的东西,我与 Material Design 2 一起使用

modifier = Modifier.alpha(if (isSelected) ContentAlpha.high else ContentAlpha.medium)
Run Code Online (Sandbox Code Playgroud)

您能解释一下,如何在 Material Design 3 中使用主题标记控制不透明度吗?谢谢。

android android-jetpack-compose material-you material-design-3

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

Selenium FireFoxDriver 无法连接

我第一次尝试使用 Selenium 来驱动 Firefox。我使用几乎相同的代码来驱动 Chrome,没有出现任何问题。但是,当我尝试使用 Firefox 驱动程序时,浏览器打开、停止,然后在大约 60 秒后,我收到如下错误报告:

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox   console output:
4474-a285-3208198ce6fd}","syncGUID":"dcskEFBTLyBH","location":"app-global","version":"48.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1471881400240,"updateDate":1471881400240,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"48.0.1","maxVersion":"48.0.1"}],"targetPlatforms":[],"seen":true}
1472056603181   addons.xpi  DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
Run Code Online (Sandbox Code Playgroud)

我检查了其他指南,他们建议我更新我的 .jar 文件。我正在使用 selenium-java-3.0.0-beta2 和 Firefox 48.0.1 进行测试,以便我的文件是最新的。我想让它正常运行。

更新:代码仍然无法工作,我已经设置了系统属性来正确设置 geckodriver。但是,我仍然无法让驱动程序正常运行。它甚至不再启动浏览器。

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class SimpleFireFoxDriver {


public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver.exe");

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", true);

   WebDriver driver = new FirefoxDriver();

   driver.get("http://www.youtube.com");

   System.out.println("Made it to …
Run Code Online (Sandbox Code Playgroud)

java firefox selenium geckodriver

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