占位的实现和间接实现从快捷建中启动一个服务
16lz
2021-01-23
1. 占位富大家都很熟悉,但是在android中没有提供,可是有时候我们想一个部分空着 但是又不让被发现
那么就使用
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/login_EditText_password" android:orientation="horizontal"> <View android:layout_width="0dip" android:layout_height="0dip" android:layout_weight="1" /> <Button android:text="@string/login_login" android:id="@+id/login_Button_login" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout>
view就是用来占位的啊。
2. 因为不能从快捷键启动服务 只能间接实行
public class MyServiceActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(this, MyService.class); startService(intent); finish(); } }
也就是说启动一个activity然后在里面启动服务
更多相关文章
- Android Studio快捷键、配置 Android Studio、cmake配置Android
- android studio 快捷键描述和设置
- android快捷键
- Android 小发现:xml里定义的组件取出始终为null
- Android studio中快捷键
- Android studio MAC和window 个人常用快捷键
- Android开发现状分析(2020版)