Titlebar title bar change text setTile Android example
Change the title associated with this activity. If this is a top-level activity, the title for its window will change. If it is an embedded activity, the parent can do whatever it wants with it.
String sTitle = "My new title";
setTitle(sTitle);
396LW NO topic_id
AD
Další témata ....(Topics)
If on Android emulator home button pressed.
Diagram of Activity lifecycle if button HOME pressed
// button home presssed
19:37:06.727: INFO/ActivityManager(60): Starting:
Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME]
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher } from pid 60
19:37:06.807: INFO/onSaveInstanceState(339): onSaveInstanceState()
19:37:06.848: INFO/onPause(339): onPause()
19:37:07.968: INFO/onStop(339): onStop()
Diagram of Activity lifecycle if button HOME pressed
In html is horizontal line a tag br. In Android source code you can use a View as xml example bellow.
<View
android:layout_width="fill_parent"
android:layout_height="4dip"
android:background="#ffffff"
android:paddingBottom="10dip"
/>
Problem: erroneous entry of id
Solution: @+id/
<RadioButton android:id="idRadio"
android:text="My radio button"/>
Solution: @+id/
<RadioButton android:id="@+id/idRadio"
android:text="My radio button"/>
Check this in XML file if use singleLine
singleLine change to maxLines (1 if singleLine)
declare inputType
singleLine change to maxLines (1 if singleLine)
declare inputType
android:maxLines="1"
android:inputType="text"
public class Main extends Activity {
private TextView mTextView;
private Activity mAct;
private Intent mIntent;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
mTextView = findViewById(R.id.mTextView);
mAct = getActivity();
mIntent = getIntent();
}
}
to:
public class Main extends Fragment{
private TextView mTextView;
private FragmentActivity mFrgAct;
private Intent mIntent;
private LinearLayout mLinearLayout;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_main, null);
return root;
}
public void onViewCreated(View view, Bundle savedInstanceState) {
// you can add listener of elements here
/*Button mButton = (Button) view.findViewById(R.id.button);
mButton.setOnClickListener(this); */
mTextView = view.findViewById(R.id.mTextView);
mLinearLayout = (LinearLayout)view;
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mFrgAct = getActivity();
mIntent = mFrgAct.getIntent(); // Intent intent = new Intent(getActivity().getIntent());
}
}
Editace: 2011-09-17 12:34:02
Počet článků v kategorii: 396
Url:titlebar-title-bar-change-text-android-example