我的项目无法在预览中呈现布局.我的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.我尝试,一切正常,预览成功.但是我创建片段活动,问题又回来了,预览无法显示. 如果您有新的解决方案,请帮助我!
我正在尝试手动从 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 中调用控制器
,我收到了这个错误:

我有一个文本文件包含这样的内容:
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 ' 需要字符串作为左操作数,而不是列表。 如何打印包含许多特定单词的句子?
我想更改我的第一个活动,首先我有一个名为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)