Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 带有片段的搜索框没有响应_Android_Fragment - Fatal编程技术网

Android 带有片段的搜索框没有响应

Android 带有片段的搜索框没有响应,android,fragment,Android,Fragment,你好,我有一个问题,当我搜索网页明天的过程是成功的,但当我搜索网页今天有一个问题,我使用了碎片 这里的问题是: 代码: public void btn_search(View view) { TextView txtexample = (TextView)findViewById(R.id.txtexample); txtexample.setText("hello"); } 碎片日 <FrameLayout xmlns:android="http://schemas.a

你好,我有一个问题,当我搜索网页明天的过程是成功的,但当我搜索网页今天有一个问题,我使用了碎片

这里的问题是:

代码:

public void btn_search(View view) {
    TextView txtexample = (TextView)findViewById(R.id.txtexample);
    txtexample.setText("hello");
}
碎片日

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.user.weather.Fragment_days">

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/txtexample"
        android:text="@string/hello_blank_fragment" />

</FrameLayout>
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_days, container, false);
    return v;
}
今天和明天都是空的

请帮助我,两周前我正在查找一个问题

请使用以下命令(注意带有
txtexample的两行代码
):


在今天或10天内搜索页面时,请退出程序。它显然会崩溃,因为您位于第一个片段上,并且您正在更改搜索按钮上最后一个片段的视图。单击该按钮位于onresume()方法中。您可以举个例子吗?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_days, container, false);

    TextView txtexample = (TextView)v.findViewById(R.id.txtexample);                                       
    return v;
}
 public void btn_search(View view) {
     txtexample.setText("hello");
 }