小编sya*_*ein的帖子

无法加载具有未知错误的AppCompat ActionBar

我的项目无法在预览中呈现布局.我的Android Studio版本3.1.2.我正在使用API​​ 28.这是我的activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/frame_container">

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="Hello World"
    android:gravity="center"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

这很简单,只是将Hello World打印到布局,但它无法显示.错误如下: 预览错误

我搜索解决问题,解决方案是使用API​​ 26.我尝试,一切正常,预览成功.但是我创建片段活动,问题又回来了,预览无法显示. 如果您有新的解决方案,请帮助我!

android

5
推荐指数
2
解决办法
3475
查看次数

消息:file_get_contents(sso.json):无法打开流:没有这样的文件或目录

我正在尝试手动从 JSON 文件中获取数据,而不是从 URL 中获取数据。我使用函数file_get_contents。我得到了错误:

消息:file_get_contents(sso.json):无法打开流:没有这样的文件或目录

即使路径是正确的。这是我的结构项目:

-> kalenderkerja
   -> application
      -> controllers
         -> agendakerja
            Kalender.php
            sso.json
   -> assets
   -> ...
Run Code Online (Sandbox Code Playgroud)

这是我在文件Kalender.php中的函数user()中的代码

public function user() {
    $url = 'sso.json';
    $data = file_get_contents($url);
    $characters = json_decode($data, true);

    echo $characters['name'];
}
Run Code Online (Sandbox Code Playgroud)

我在浏览器localhost/kalenderkerja/agendakerja/kalender/user 中调用控制器 ,我收到了这个错误: 在此处输入图片说明

php json

4
推荐指数
1
解决办法
3625
查看次数

在文本文件中查找特定单词并使用 Python 打印该行

我有一个文本文件包含这样的内容:

Saya makan nasi padang semalam。Lauk yang aku pesan adalah ikan gurame。哈尔加尼亚玛哈尔。Aku juga makan dengan ayah dan ibuku。Setelah itu,Rina datang menemuiku。

我想在文本文件中找到特定的单词,然后打印包含特定单词的句子。我有很多具体的话。我尝试这样编码:

with open("kalimat.txt",'r') as f:
text = f.read()
# f.close()

words = ["makan","Rina","mahal"]

for item in text.split("\n"):
  if words in item:
    print(item.strip())
Run Code Online (Sandbox Code Playgroud)

我收到错误TypeError: 'in ' 需要字符串作为左操作数,而不是列表。 如何打印包含许多特定单词的句子?

python

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

如何更改Android Studio中的首次活动?

我想更改我的第一个活动,首先我有一个名为MainActivity的活动。然后添加名为ActivityFirst的活动。当然,我必须更改AndroidManifest.xml。以前我有这样的androidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="edmt.dev.androidsimsimi">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

在添加新活动后,还更改了androidManifest文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="edmt.dev.androidsimsimi">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".ActivityFirst">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

添加ActivityFirst之后,我将MainActivity放在哪里感到困惑。这是我的ActivityFirst.java

public class ActivityFirst extends AppCompatActivity {

  private Button mulai;
  @Override
  protected …
Run Code Online (Sandbox Code Playgroud)

java xml android

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

标签 统计

android ×2

java ×1

json ×1

php ×1

python ×1

xml ×1