You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

package com.example.test1;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
public class SetContentFragment extends Fragment{
private View view;
private TextView text1,text2;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//获取布局文件
view=inflater.inflate(R.layout.content_layout,container,false);
if (view!=null){
init();
}
//获取activity中设置的文字
setText(((com.example.test1.Fragment)getActivity()).getSettingText()[0]);
return view;
}
private void init() {
text1=(TextView)view.findViewById(R.id.show_title);
text2=(TextView)view.findViewById(R.id.show_content);
}
public void setText(String[] text) {
Log.i("news",text[0]);
text1.setText(text[0]);
text2.setText(text[1]);
}
}