我正试图通过额外传递类名,怎么做?
Intent p = new Intent(StartScreen.this, Setting.class);
p.putExtra(" ",StartScreen.this);
Run Code Online (Sandbox Code Playgroud)
我想在Setting类中获取类名,但我不希望它是String
因为我将使用这样的类名:
Bundle extras = getIntent().getExtras();
extras.getString("class");
Intent i = new Intent(Setting.this, class);
startActivity(i);
Run Code Online (Sandbox Code Playgroud) 我看到一些关于这个的帖子,我理解了这个问题.但怎么能绕过它呢?我有ListView
可以扩展的项目但是一旦视图消失,它就不能再次可见,除非它有一个空闲空间.如何制作那个空间?
private void mySetOnItemListener() {
l.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long arg3) {
Log.d("onItemClick","called");
LinearLayout ll = (LinearLayout)view.findViewById(R.id.llOpenedField);
ll.setVisibility(View.VISIBLE);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我的viewLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="5" >
<TextView
android:id="@+id/tv_name"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="4"
android:padding="7dp"
android:text="item"
android:textColor="@android:color/background_dark"
android:textSize="25dp" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llOpenedField"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
>
<ImageButton
android:id="@+id/ibInformation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/info" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这LinearLayout
android:id="@+id/llOpenedField"
是我试图gone …
我正在使用MediaPlayer来显示SplashVideo,并且日志充满了详细的消息.这不是错误,但仍然不是正常行为.
Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.logo_vid);
videoHolder.setVideoURI(video);
videoHolder.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
jumpMain();
}
});
videoHolder.start();
}
Run Code Online (Sandbox Code Playgroud)
这是日志......
08-01 12:52:16.045: V/MediaPlayer(12402): setListener
08-01 12:52:16.045: I/MediaPlayer(12402): path is null
08-01 12:52:16.045: V/MediaPlayer-JNI(12402): setDataSourceFD: fd 43
08-01 12:52:16.045: V/MediaPlayer(12402): setDataSource(43, 1088, 407705)
08-01 12:52:16.085: V/MediaPlayer(12402): setVideoSurfaceTexture
08-01 12:52:16.085: V/MediaPlayer-JNI(12402): setAudioStreamType: 3
08-01 12:52:16.085: V/MediaPlayer(12402): MediaPlayer::setAudioStreamType
08-01 12:52:16.085: V/MediaPlayer(12402): setVideoSurfaceTexture
08-01 12:52:16.085: V/MediaPlayer(12402): prepareAsync
08-01 12:52:16.265: V/MediaPlayer(12402): message received msg=5, ext1=360, ext2=480
08-01 12:52:16.265: V/MediaPlayer(12402): …
Run Code Online (Sandbox Code Playgroud) 我做了自定义视图,使用此constractors扩展textView:
// Default constructor override
public AutoResizeTextView(Context context) {
this(context, null);
}
// Default constructor when inflating from XML file
public AutoResizeTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
Run Code Online (Sandbox Code Playgroud)
如何将它添加到android studio中的调色板?
我看到了允许选择自定义视图的按钮但是在我点击之后没有任何反应:
点击我希望窗口关闭的课程后,没有任何事情发生......
我想通知开发人员一个方法需要在主线程中,所以我写了以下代码:
@MainThread
public void showToast(@NonNull String text) {
Toast.makeText(this, text, Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
比我写的:
new Thread(new Runnable() {
@Override
public void run() {
showToast("");
}
}).start();
Run Code Online (Sandbox Code Playgroud)
并且编译器没有将此标记为错误,与@StringRes
我使用的其他注释不同.
任何想法为什么?
我在使用 gradlew 和 Java 17 构建 Android 项目时遇到问题。我收到的错误消息是:
“无法解析 androidx.navigation:navigation-safe-args-gradle-plugin - '在编译时使用的组件,与 Java 17 兼容,而消费者需要在运行时使用的组件,与 Java 13 兼容'”
但是,当我通过 Android Studio 构建并运行应用程序时,一切正常。作为 CI 流程的一部分,此错误也会出现在我的 Git Actions 工作流程中。
我的项目需要 Java 版本 17。谁能帮助我理解为什么使用 gradlew 时会出现此错误以及如何解决它?
此外,我很好奇 Android Studio 正在运行的确切命令,因为该项目使用 GUI 成功构建了。了解该命令可能有助于深入了解该问题。
完整信息:
MacBook-Pro:My-Android me$ ./gradlew
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'My-Android'.
> Could not resolve all files for configuration ':classpath'.
> …
Run Code Online (Sandbox Code Playgroud) 我有两个问题我想了解.
我正在使用soundPool
我的声音效果,它的工作没有问题.但是,当我尝试播放cetain文件(25秒,大约400K)时,它不会播放整个文件仅3-4秒.
为什么以及如何解决它?
第二个问题是,我应该从线程中播放每个效果吗?很多线程都不错?
这是当前的代码:
static void play(final int soundID ){
if(loaded){
handler.post(new Runnable()
{
public void run()
{
soundpool.play(soundID, 1, 1, 1, 0, 1);
}
});
Run Code Online (Sandbox Code Playgroud) 我已经导入了elses项目,我看到3个清单文件.一个用于main,一个用于测试,另一个用于根文件夹.
拥有多个清单有什么好处?例如,如果我将活动设置为一个文件中的单个任务而另一个文件中的单个顶部,则该项目如何使用多个项目构建?
如果有人能解释它是如何工作的,那么处理这个问题的正确方法是什么.
可能是因为我无法降级Android Gradle插件版本的原因是什么?
我已更新到Gradle plugin 2.0
现在,我想使用1.5,但我安装的Android Studio说:
> Error:The project is using an incompatible version of the Android
> Gradle plugin. Please update your project to use version 2.1.0
classpath 'com.google.gms:google-services:2.0.0-alpha6'
Run Code Online (Sandbox Code Playgroud)
广告在Google Analytics最新版本中请求,但Gradle无法正常工作,所以我想返回1.5.
这是我的Gradle文件:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
repositories {
mavenCentral()
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud) 我想在每次构建时上传 NDK 符号,
在我的 Android 里面 gradle 我曾经拥有:
applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
println("symbols will be added on varinat ${variantName}")
def task = project.task("ndkBuild${variantName}")
task.finalizedBy project.("uploadCrashlyticsSymbolFile${variantName}")
}
Run Code Online (Sandbox Code Playgroud)
自从我搬到 FireBase 后,这不再编译:
无法获取未知属性“uploadCrashlyticsSymbolFile”
我没有看到这个任务在运行。
我基本上需要在每个构建上运行这个任务:
./gradlew app:assembleBUILD_VARIANT\ app:uploadCrashlyticsSymbolFileBUILD_VARIANT
我想知道按下了哪个按钮,所以我在 onReceive 上执行此操作
Log.e(TAG, "Clicked " + extras.getInt("ACTION"));
Run Code Online (Sandbox Code Playgroud)
而且我总是,无论我按哪个按钮,都会得到 3 (ActionEnum.GO_TO_REMINDERS)
,即setContentIntent
.
另一个问题是,除非我按下通知好友,否则通知不会关闭,但是当我按下按钮时它不会关闭。
public void createNotification(Context context, Reminder reminder) {
// Build notification
Notification noti = new Notification.Builder(context)
.setContentTitle(reminder.getDisplayString())
.setContentText("Pick Action")
.setSmallIcon(R.drawable.icon_remider)
.setContentIntent(
getPendingAction(context, reminder,
ActionEnum.GO_TO_REMINDERS))
.addAction(R.drawable.icon, "Take",
getPendingAction(context, reminder, ActionEnum.TAKE))
.addAction(R.drawable.icon, "Snooze",
getPendingAction(context, reminder, ActionEnum.SNOOZE))
.addAction(R.drawable.icon, "Remove",
getPendingAction(context, reminder, ActionEnum.REMOVE))
.build();
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
}
public PendingIntent getPendingAction(Context context, Reminder reminder,
ActionEnum …
Run Code Online (Sandbox Code Playgroud) 我是palassUser的子类,所以当我寻找用户我使用:
query.getFirstInBackground(new GetCallback<MySubClass>() {
@Override
public void done(MySubClass user, ParseException e) {
Run Code Online (Sandbox Code Playgroud)
但是当我需要用户getCurrentUser或logInInBackground时,我得到的是ParseUser而不是MySubClass.
我用这个方法:
MySubClass.logInInBackground(userName, "", new LogInCallback() {
@Override
public void done(ParseUser u, ParseException arg1) {
}
});
Run Code Online (Sandbox Code Playgroud)
但我希望回调像我的查询中一样返回MySubClass对象.
与此相同:
MySubClass.getCurrentUser()
Run Code Online (Sandbox Code Playgroud) 我见过这个问题
为什么警告:无法找到可选库:org.apache.http.legacy发生?
还有更多,但问题没有解决,我使用目标23,我不想,所以现在当我回到目标21我收到此错误:
警告:无法找到可选库:org.apache.http.legacy
是的我有optional.json文件,是的,我已经尝试将apache放在我的lib文件夹中,但是这个错误仍然会发生,我被困在这很长时间了.
android ×10
gradle ×3
view ×2
android-ndk ×1
annotations ×1
api ×1
class ×1
crashlytics ×1
extra ×1
firebase ×1
handler ×1
java ×1
lag ×1
listener ×1
listview ×1
media-player ×1
metadata ×1
palette ×1
push ×1
return-type ×1
setting ×1
soundpool ×1
subclass ×1
target ×1
visibility ×1