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");
}