我刚刚为Android Mobile 和 Wear 创建了一个新的Android Studio项目.初始gradle构建失败,因为我收到了几个错误 -
Error: Failed to resolve: com.android.support:support-v4:26.0.0
Error: Failed to resolve: com.android.support:percent:26.0.0
Error: Failed to resolve: com.android.support:recyclerview-v7:26.0.0
Error: Failed to resolve: com.android.support:support-annotations:26.0.0
对于每个错误,我都可以选择Install repository and sync project,但是当我点击它时没有任何反应.我花了几个小时试图找到我收到这些错误的原因,但我找不到任何解决方案.有谁知道如何解决这些非常令人沮丧的错误?谢谢!
build.gradle(项目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module …Run Code Online (Sandbox Code Playgroud) 我按照本教程将 Firebase 用户身份验证添加到我的 SwiftUI 项目中。当用户登录或注册时,登录视图应该消失,而应该出现显示“登录成功”的文本。然而,这不会发生。登录/注册过程似乎有效,但视图没有改变,我怀疑EnvironmentalObject. 有没有人对为什么会发生这种情况有一些想法?谢谢!
这是我的一些代码 -
AppDelegate.swift
...
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContentView().environmentObject(SessionStore()))
self.window = window
window.makeKeyAndVisible()
}
}
...
Run Code Online (Sandbox Code Playgroud)
内容视图.swift
import SwiftUI
struct ContentView : View {
@EnvironmentObject var session: SessionStore
func getUser () {
session.listen()
}
var body: some View {
VStack {
if (session.session == nil) {
SignInView() …Run Code Online (Sandbox Code Playgroud) 在我创建的应用程序中,我有一个项目列表.当用户点击其中一个项目时,应该打开一个新窗口,在用户点击的项目内显示信息.这是我的java代码 -
NoteListFragment.java public class NoteListFragment extends Fragment {
public class NoteListFragment extends Fragment {
private FloatingActionButton mFab;
private View mRootView;
private List<Note> mNotes;
private RecyclerView mRecyclerView;
private NoteListAdapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
public NoteListFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment and hold the reference
//in mRootView
mRootView = inflater.inflate(R.layout.fragment_note_list, container, false);
//Get a programmatic reference to the Floating Action Button
mFab …Run Code Online (Sandbox Code Playgroud) 我正在使用Android Studio为Android创建应用.我有一个代码块,收集一些字符串,将它们转换为双精度数,将它们放入方程式,然后将答案放入TextViews,只有两个小数位.
double weightDouble = Double.parseDouble(weightTextField.getText().toString());
double dehydrationDouble = Double.parseDouble(dehydrationTextField.getText().toString());
double lossesDouble = Double.parseDouble(lossesTextField.getText().toString());
double factorDouble = Double.parseDouble(factorTextField.getText().toString());
double fluidStepOne = (((Math.sqrt(Math.sqrt((weightDouble * weightDouble * weightDouble))))) * 70) * factorDouble;
double fluidStepTwo = fluidStepOne + (weightDouble * dehydrationDouble * 10);
double fluid24Hours = fluidStepTwo + lossesDouble;
double fluidHourInt = fluid24Hours / 24;
fluidResultLabel.setText(String.format(Locale.US, "%.2f", Double.toString(fluid24Hours)));
fluidPerHourResultLabel.setText(String.format(Locale.US, "%.2f", Double.toString(fluidHourInt)));
Run Code Online (Sandbox Code Playgroud)
但是,当运行此代码块时,应用程序崩溃,Android Studio说这个 -
java.util.IllegalFormatConversionException: %f can't format java.lang.String arguments
at java.util.Formatter.badArgumentType(Formatter.java:1489)
at java.util.Formatter.transformFromFloat(Formatter.java:2038)
at java.util.Formatter.transform(Formatter.java:1465)
at java.util.Formatter.doFormat(Formatter.java:1081)
at java.util.Formatter.format(Formatter.java:1042)
at java.util.Formatter.format(Formatter.java:1011)
at …Run Code Online (Sandbox Code Playgroud) 我试图在我的UINavigationBar中设置标题颜色AppDelegate.swift,像这样 -
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UINavigationBar.appearance().barTintColor = UIColor(red: 26.0/255.0, green: 188.0/255.0, blue: 156.0/255.0, alpha: 1.0)
UINavigationBar.appearance().tintColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: UIFont(name: "Pacifico", size: 24)!]
// Turquoise color rgba(26, 188, 156,1.0)
return true
}
Run Code Online (Sandbox Code Playgroud)