In fact, I don't learn much, I just understand others, and then change it to my own, so for some common points of knowledge sometimes I can't write them out by myself, so sort out my commonly used small points of knowledge.
1. Frequently asked questions about creating an activity
The newly created activity must be configured in the manifest file, otherwise the system cannot find it and will directly error when displaying it, so be sure to remember to add it in AndroidManifest.xml when creating the activity
<activity android:name="com.dml.bluetooth.ChartView">
Note that if you have the following code when copying the original activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
If you add this code, there will be two icons for this application. That's okay. They are the same application, just like making phone calls and sending text messages. In fact, they are the same application. Only two icons appear. If you need such functions in development, you can add the above code to achieve them.
2. Jump between two activities
Jump to the app that comes with your phone
public void write_Click(View v){
Intent intent = new Intent();
//Set the appropriate action here
//Call action: Intent.ACTION_CALL
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:110"));
startActivity(intent);
}
Jump to the specified activity
Mode 1. Jump by specifying activity
public void write_Click(View v){
Intent intent = new Intent();
//The first parameter is the current activity, and the second parameter is the activity to jump to
intent.setClass(this, WritrActivity.class);
//Always remember to write this, or you won't be able to jump
startActivity(intent);
}
Mode 2. Jump by specifying a package name
public void write_Click(View v){
Intent intent = new Intent();
//Specify package and class names for the target Activity
intent.setClassName("com.android.dialer", "com.android.dialer.DialtactsActivity");
startActivity(intent);
}
Mode 3. Implicitly jump to the same activity as the application, and child nodes must be added to the manifest file
<intent-filter>
<action android:name="com.question.write" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
The name of the activity node is self-defined, and once defined, the value of the name becomes this
The action of the activityWhen the activityis started, the value of the action set in the intent is this name value
public void write_Click(View v){
Intent intent = new Intent();
//cls: Specify the class name of the target Activity directly
intent.setAction("com.question.write");
//The default category is automatically added
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
}
3. Control Hiding
v1.setVisibility(View.VISIBLE); //Normal display
v1.setVisibility(View.INVISIBLE); //Hide participating layouts (still occupying space)
v1.setVisibility(View.GONE); //Hide non-participating layouts (no space)
4. Remove the title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//Remove title bar
Note: This code is written in front of setContentView().
5. Dynamic View Generation in Java Code
Generating View s Dynamically in Java Code
The article is well written
6. Control prohibits clicking events
btn_send.setEnabled(false);//Disable Click Events
btn_send.setEnabled(true);//Allow Click Events
7. Set button by code once Click
btn_device.performClick();
8. Layout File
android:singleLine="true" //Single line display, no line wrapping,...Express
//Content Show Two Lines
android:lines="2"
I found them temporarily, and then I thought I was filling them up.