我正在尝试安装该应用程序,但 Android Studio 显示错误:
Launching 'app' on Xiaomi Redmi 4A.
Installation did not succeed.
The application could not be installed.
...
Installation failed due to: 'Connection refused: connect'
Run Code Online (Sandbox Code Playgroud)
我该如何修复这个错误?
如何更改 Visual Studio 中的默认缩进?
我希望它始终使用制表符而不是空格。
在我看过的所有地方,它要么没有告诉我如何将选项卡设置为默认选项,要么已经过时了好几年。
编辑:
有点尴尬,我已经解决了问题。右下角的小部件仍然表示它正在使用空格,尽管它使用的是制表符。当我发现这些设置时,我感到非常沮丧,所以我没有测试它们是否有效(尽管右下角的小部件不会更新对我来说有点奇怪)。
我正在关注 SwiftUI 放大应用程序的本教程,在创建符合 Bindable 对象的最终类时遇到此错误。
Error:Use of undeclared type 'BindableObject'
import Combine
import SwiftUI
import AWSAppSync
final class TalkStore: BindableObject {
/*
Required by SwiftUI
*/
let didChange = PassthroughSubject<TalkStore, Never>()
var listTalks: [ListTodosQuery.Data.ListTodo.Item] {
didSet {
didChange.send(self)
}
}
//We will be using this later.
private let appSyncClient: AWSAppSyncClient!
/*
Init if running app is using SwiftUI Content View
*/
init(talks: [ListTodosQuery.Data.ListTodo.Item]) {
self.appSyncClient = nil
self.listTalks = talks
}
}
Run Code Online (Sandbox Code Playgroud)
苹果是否有可能更改了类名?
我怎么知道?
如何使按钮文本自动调整其大小以适合按钮?
我尝试过设置:
android:autoSizeTextType="uniform"
Run Code Online (Sandbox Code Playgroud)
但这行不通。
如果我输入以下内容,文本仍然以两行结束:
android:maxLines="1"
Run Code Online (Sandbox Code Playgroud)
文本的某些部分消失了。
是否有任何方法(以编程方式或在 XML 中)自动调整文本大小以适合一行上的按钮,并且还显示整个文本?
编辑 :
这是我的 XML,我想要放入文本的按钮是“btnReq”和“btnAcc”:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".PlayFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_constraintBottom_toTopOf="@+id/tableLayout"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.074"
tools:layout_editor_absoluteX="0dp">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingRight="10dp">
<EditText
android:id="@+id/et_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ems="10"
android:hint="email"
android:inputType="textPersonName"
android:autoSizeTextType="uniform"/>
<Button
android:id="@+id/btnReq"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="REQUEST"
android:autoSizeTextType="uniform"
android:maxLines="1"/>
<Button
android:id="@+id/btnAcc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ACCEPT"
android:autoSizeTextType="uniform"
android:maxLines="1"/>
</LinearLayout>
</LinearLayout>
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:padding="10dp"
app:layout_constrainedHeight="false"
app:layout_constraintBottom_toBottomOf="parent" …Run Code Online (Sandbox Code Playgroud) 我正在尝试逐像素显示位图图像(这明确意味着有一些延迟)。
为此,我使用两个“for 循环”,但它只打印单行像素......
我的代码:
Button start = (Button) findViewById(R.id.start);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Toast.makeText(getBaseContext(), "Printing...", Toast.LENGTH_SHORT).show();
iImageArray = new int[bMap.getWidth()* bMap.getHeight()]; //initializing the array for the image size
bMap.getPixels(iImageArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight()); //copy pixel data from the Bitmap into the 'intArray' array
//Canvas canvas = new Canvas (bMap);
//replace the red pixels with yellow ones
for (int i=0; i < bMap.getHeight(); i++) {
for(int j=0; j<bMap.getWidth(); j++) {
iImageArray[j] = 0xFFFFFFFF;
} …Run Code Online (Sandbox Code Playgroud) 我们正在开发一个通过蓝牙使用 SPP(串行端口配置文件)的应用程序,开发人员正在讨论使用某种类型的协议和数据包传输,还是仅在没有任何形式的 ACK、序列或大小信息的情况下流式传输数据。
蓝牙是否提供有保证的传输和数据完整性,以便我们不需要数据包协议设计的开销?
我们可以仅依靠蓝牙来确保数据传输吗?
我已经阅读了很多有关创建图标,然后在Visual Studio项目->属性->图标和清单中分配这些图标之一的文章。这样做时,我收到一条消息,指出该图标无效。我一直这样做的主要方式是使用MSPaint。
这是当我在MSPaint中保存一个24位图标时,在我读过的一篇文章中提到了这一点。我在Visual Studio 2012的图像编辑器中找不到任何编辑功能。那么,如何为应用程序创建一个简单的图标?
我知道那里有免费的转换器。我特别在问是否有一种方法可以使用现有工具(如Visual Studio,MSPaint等)进行转换。
icons image-editor visual-studio visual-studio-2012 visual-studio-2017
作为 Android 编程的新手,我已将四个文件附加到我的库的资产文件夹中。
您可以看到附图。
我想使用下面的代码通过 Android 库访问这些文件(如果我不在 Android 库中使用此代码,则当我在 MainActivity 中使用它时,它运行时不会出现错误)。
public void copy_weights() {
try {
AssetManager assetFiles = getAssets();
String[] files = assetFiles.list("");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace(); //catch the error in this line
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
但这段代码给了我错误:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.Context.getAssets' on a null object refrence
我尝试了其他方法,例如直接访问home:///android_asset/7.cfg,但也无法访问文件。
编辑1
我像下面这样copy_weights()调用mainActivity
public class MainActivity extends AppCompatActivity {
@Override …Run Code Online (Sandbox Code Playgroud) 我需要在单个R会话中创建多个临时目录,但是每次调用tempdir()时,我都会得到相同的目录。
有没有一种简单的方法来确保每个呼叫都会给我一个新的临时目录?
我正在创建一个小算法,这是其中的一部分。
如果用户输入非整数值,我想输出一条消息并让用户再次输入一个数字:
boolean wenttocatch;
do
{
try
{
wenttocatch = false;
number_of_rigons = sc.nextInt(); // sc is an object of scanner class
}
catch (Exception e)
{
wenttocatch=true;
System.out.println("xx");
}
} while (wenttocatch==true);
Run Code Online (Sandbox Code Playgroud)
我得到了一个永无止境的循环,我不知道为什么。
如何识别用户是否输入了一些非整数?
如果用户输入一个非整数,我如何要求用户再次输入?
更新
当我打印异常时,我收到“InputMismatchException”,我该怎么办?
java input try-catch java.util.scanner inputmismatchexception
android ×4
java ×2
aws-amplify ×1
bitmap ×1
bluetooth ×1
c# ×1
connection ×1
icons ×1
image ×1
image-editor ×1
indentation ×1
input ×1
ios ×1
kotlin ×1
launch ×1
pixel ×1
protocols ×1
r ×1
spp ×1
swift ×1
swiftui ×1
temp ×1
transmission ×1
try-catch ×1