模仿安卓系统原生的亮度调节框 --->Android弹出框
墨香Launcher
Fragment+Activity结构
工具类
简书
codewars
C
源码
public class HintActivity extends AppCompatActivity {
public static final String TAG = "HintActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hint);
}
@Override
protected void onStop() {
super.onStop();
Toast.makeText(this,"HintActivity onStop",Toast.LENGTH_SHORT).show();
}
}
// 布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:background="#E40F0F">
<Button
android:id="@+id/confirm"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom ="true"
android:background="#E4DADA"
android:textSize="35dp"
android:text="text" />
</RelativeLayout>
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button hint;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main7);
hint = findViewById(R.id.hintClick);
hint.setOnClickListener(this::onClick);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.hintClick:
Toast.makeText(this,"to into HintActivity ",Toast.LENGTH_SHORT).show();
Intent intent = new Intent("android.intent.action.SHOWHINTACTIVITY");
startActivity(intent);
break;
}
}
}
// AndroidManifest.xml 配置方式
<activity
android:name=".demo1.HintActivity"
android:excludeFromRecents="true"
android:exported="true"
android:theme="@style/Theme.AppCompat.Dialog">
<intent-filter>
<action android:name="android.intent.action.SHOWHINTACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".demo1.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
分类:
Android
, Android-自定义控件-学习记录
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库