当我的程序中的某个标志被设置时,我发送意图,然后在 BroadcastReceiver 中接收这个意图。我不知道如何从这里更新标签片段。有什么建议或例子吗?
设置标志时我得到这个日志,但我不知道如何从那里:
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "hello :)", Toast.LENGTH_LONG).show();
}
}
感谢帮助!
分段:
public class FragmentInfo extends Fragment {
private TextView textView1;
private TextView textView3;
private TextView textView5;
private TextView textView7;
private TextView textView8;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.fragment_info, container, false);
connectButton = (Button) myFragmentView.findViewById(R.id.button1);
changeSettingsButton = (Button) myFragmentView.findViewById(R.id.button2);
erraseFlightsButton = (Button) myFragmentView.findViewById(R.id.button3);
//TextView for status of connected device..
textView1 = (TextView)myFragmentView.findViewById(R.id.TextView1);
//TextView for Device name
textView3 = (TextView)myFragmentView.findViewById(R.id.TextView3);
//TextView for Serial number
textView5 = (TextView)myFragmentView.findViewById(R.id.TextView5);
//TextView for Software version
textView7 = (TextView)myFragmentView.findViewById(R.id.TextView7);
//TextView for Connected Device version
textView8 = (TextView)myFragmentView.findViewById(R.id.TextView8);
return myFragmentView;
}
}