<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/list"
android:name="com.example.studytest06.ListFragment1"
android:layout_weight="1"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:name="com.example.studytest06.DetailFragment"
android:id="@+id/detail"
android:layout_weight="1"/>
</LinearLayout>
package com.example.studytest06;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class DetailFragment extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail_fragment);
}
}
package com.example.studytest06;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ListFragment1 extends AppCompatActivity {
// public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_list, container, false);
// return view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_fragment1);
}
}
package com.example.studytest06;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
public class MainActivity extends Activity {
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==0x11&&requestCode==0x11){
Bundle bundle=data.getExtras();
int imageId=bundle.getInt("imageId");
ImageView imageView=findViewById(R.id.touxiang);
imageView.setImageResource(imageId);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main1);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".DetailFragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Detail Fragment"
android:textSize="30sp"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".ListFragment1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ListView Fragment"
android:textSize="30sp"/>
</LinearLayout>
请问这里为什么显示不出来啊?详解必采纳。我想要的效果图: