我想在textView中有一些简单的文字..
喜欢......(android和java)
意思是我完全需要"和"符号 textView
如果我在TextView android:text="Bakeries & Dessert"中提供textView它在xml中显示错误.
任何人都可以建议我如何忽略特殊情况字符&,"等等,并将它们放在我们的TextView文本中.
我使用RecyclerView适配器来显示活动内部的数据,我想onClickListener在活动内部实现,目前,我onClickListener正常设置内部适配器,工作正常.
public void onBindViewHolder(MyHolder holder, final int position) {
final Listdata data = listdata.get(position);
holder.vname.setText(data.getName());
holder.vname.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(activity, "clicked on " +position, Toast.LENGTH_SHORT).show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
但是我想在活动中实现它,所以我有更大的控制权.这不符合我的目的.我认为这对我们很多人都有用.
尝试创建发布签名的 apk 时,构建在任务中失败
app:uploadCrashlyticsMappingFileRelease'.Host name must not be empty.
我已经启用了混淆功能。
buildTypes {
release {
minifyEnabled true // Enables code shrinking, obfuscation, and optimization
shrinkResources true // Enables resource shrinking, which is performed by the Android Gradle plugin
firebaseCrashlytics {
mappingFileUploadEnabled true
}
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Run Code Online (Sandbox Code Playgroud)
另外,使用
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
// Apply the Crashlytics Gradle plugin
apply plugin: 'com.google.firebase.crashlytics'
implementation 'com.google.firebase:firebase-auth:20.0.1'
implementation 'com.google.firebase:firebase-firestore:22.0.1'
implementation 'com.google.firebase:firebase-core:18.0.0'
//the Firebase SDK for Google Analytics.
implementation 'com.google.firebase:firebase-analytics:18.0.0'
//the Firebase …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装 virtualbox。我以前安装过它,它工作正常。今天我尝试添加另一个虚拟机,它开始抱怨 dkms 的问题,所以我尝试清除并安装所有内容,但出现以下故障。
$ sudo apt install virtualbox
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dkms libgsoap-2.8.91 libqt5opengl5 libsdl1.2debian libvncserver1 virtualbox-dkms virtualbox-qt
Suggested packages:
Run Code Online (Sandbox Code Playgroud)
我无法在不跳过某些输出的情况下提交我的问题
Building initial module for 5.8.0-36-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/virtualbox-dkms.0.crash'
Error! Bad return status for module build on kernel: 5.8.0-36-generic (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.10/build/make.log for more information.
dpkg: error processing package virtualbox-dkms (--configure):
installed virtualbox-dkms package post-installation script subprocess returned …Run Code Online (Sandbox Code Playgroud) ubuntu virtualbox dkms virtualbox-guest-additions ubuntu-20.10
我最近更新到 Android 3.3,现在很多依赖项都改成了AndroidX. 这导致应用程序崩溃,并且还需要更改依赖项XML。我遇到了类似的问题CoordinatorLayout。我搜索了stackoverflow,关于这个主题的问题并不多,因为AndroidX它相对较新。所以我觉得有必要在这方面提出一个问题。
我在哪里可以获得FloatingActionButton类似的xmlXML是否有一个网站,我们可以在那里获得 androidX 依赖项的 XML。
XML
<android.support.design.widget.FloatingActionButton
Run Code Online (Sandbox Code Playgroud)
崩溃日志
android.view.InflateException:二进制 XML 文件第 15 行:二进制 XML 文件第 15 行:错误膨胀类 android.support.design.widget.FloatingActionButton 引起:android.view.InflateException:二进制 XML 文件第 15 行:错误膨胀类 android.support.design.widget.FloatingActionButton 引起:java.lang.ClassNotFoundException:在路径上找不到类“android.support.design.widget.FloatingActionButton”:DexPathList[[zip file”/data/app/com .kc.unsplashdemo-kTZQS-p2845Xly7PcTuAmg==/base.apk”,压缩文件“/data/app/com.kc.unsplashdemo-kTZQS-p2845Xly7PcTuAmg==/split_lib_dependencies_apk.apk”,压缩文件
依赖
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':androidunsplash')
implementation 'com.squareup.picasso:picasso:2.71828'
implementation("com.squareup.okhttp3:okhttp:3.12.0")
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个带有自定义LinearGradient可绘制对象的搜索栏。但是,我希望能够更改每种颜色的渐变比例,这里我使用 3 种颜色,如果positions是,它们会均匀分布null。我想要的,其实是提供宽度或比于每种颜色,例如红色的变化率,并将其设置只形成0%至10%的seekBar width。
在这里,我想设置 0% 到 10% 的红色、10% - 80% 的黄色和 80% 到 100% 的红色,并且能够动态更改每种颜色的宽度值。
这是可能的,如果是,有人可以指导我如何操作吗?
我的代码
private ShapeDrawable getSeekBarGradientDrawable(int mRectWidth, int mRectHeight) {
int[] colors = new int[] { Color.RED, Color.YELLOW, getResources().getColor(R.color.primaryButton, null)};
DisplayMetrics displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int width = displayMetrics.widthPixels - (int) getResources().getDimension(R.dimen.margin_padding_size_medium);
Shader shader = new LinearGradient(
0,
0,
width,
mRectHeight,
colors, new float[] {0.1f,0.7f,0.2f},
Shader.TileMode.CLAMP);
ShapeDrawable shape = new ShapeDrawable(new RectShape());
shape.getPaint().setShader(shader);
return …Run Code Online (Sandbox Code Playgroud) java android android-seekbar material-design android-graphics
为了保持代码最少,我希望能够在 java 中创建自定义对象的列表。类似于我们在C#or 中所做的Swift,我们以这种方式定义列表的构造函数或参数,我们不必为列表创建单独的对象和构造函数。
例如
var menuList: [(category: String, name: String, ismulti: Bool)] = [
(category: "Categ1", name: "name1", ismulti: true),
(category: "Categ2", name: "name2", ismulti: false),
(category: "Categ3", name: "name3", type: ismulti: true),
]
Run Code Online (Sandbox Code Playgroud)
这里var menuList: [(category: String, name: String, ismulti: Bool)]减少了对对象和构造函数的需要。java中有没有类似的东西?
与我在 Java 中所做的相同。
public class Menu{
String category;
String name;
boolean isMulti;
public Menu(String category, String name, boolean isMulti) {
this.category = category;
this.name = name;
this.isMulti = isMulti;
}
public …Run Code Online (Sandbox Code Playgroud) 好的,我之前已将应用内购买添加到应用程序中,但这次警告并没有消失。在控制台中,我收到此消息“应用程序还没有任何应用程序内产品。”
在 Google Play Console 中,我上传了一个应用程序,我正在使用Android-in-app-Billing-v3-light。它是来自 github 的应用内计费库。我已添加权限
<uses-permission android:name="com.android.vending.BILLING"/>
Run Code Online (Sandbox Code Playgroud)
这个警告似乎并没有消失。我做错了什么?谷歌游戏是否改变了它的要求?为什么它不允许我通过这个屏幕或警告。大多数问题都有一些权限错误,但我已经添加了权限。还发布了该应用程序的 alpha 版。
有了测试ID,它就显示出来了。
我正在关注的罗马数字到整数转换器:
https://www.selftaughtjs.com/algorithm-sundays-converting-roman-numerals/
我尝试将 Javascript 函数转换为 Java:
public class RomanToDecimal {
public static void main (String[] args) {
int result = 0;
int[] decimal = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
String[] roman = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
// Test string, the number 895
String test = "DCCCXCV";
for (int i = 0; i < decimal.length; i++ ) {
while (test.indexOf(roman[i]) == 0) {
result …Run Code Online (Sandbox Code Playgroud) 我有一个父级Horizontal Recycleview,其中包含十二个Vertical Recycleviews。我想每页仅显示两列,仅在一个水平行上。我用GridLayoutManager。
GridLayoutManager layoutManager = new GridLayoutManager(this,1);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
Run Code Online (Sandbox Code Playgroud)
增加跨度会2创建我不想要的两行。
我还尝试layout:width在 xml 中固定值dpor ,sp这会导致不同屏幕尺寸上的列数不同。
每个块的xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/view_table_view_game_block_constraint_layout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="@drawable/shape_round_top"
android:layout_marginTop="8dp">
<TextView
android:id="@+id/textView_table_view_odds_block_time"
android:layout_width="0dp"
android:layout_height="50sp"
android:gravity="center_vertical"
android:textColor="@color/colorFontWhite"
android:textSize="@dimen/font_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button_table_view_odds_block_hometeam"
android:layout_width="0dp"
android:layout_height="50sp"
android:layout_marginTop="4dp"
android:textAlignment="textStart"
android:background="@android:color/transparent"
android:textColor="@color/colorFontWhite"
android:textSize="@dimen/font_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_table_view_odds_block_time" />
<Button
android:id="@+id/button_table_view_odds_block_drawable"
android:layout_width="0dp"
android:layout_height="50sp"
android:layout_marginTop="4dp"
android:background="@android:color/transparent"
android:textAlignment="textStart"
android:textColor="@color/colorFontWhite"
android:textSize="@dimen/font_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_table_view_odds_block_hometeam" />
<Button …Run Code Online (Sandbox Code Playgroud) android android-layout android-gridlayout android-recyclerview
android ×7
java ×5
androidx ×1
arrays ×1
billing ×1
crashlytics ×1
dependencies ×1
dkms ×1
google-play ×1
gridview ×1
layout ×1
loops ×1
obfuscation ×1
proguard ×1
ubuntu ×1
ubuntu-20.10 ×1
virtualbox ×1
xml ×1