跳转到帖子

游客您好,欢迎来到黑客世界论坛!您可以在这里进行注册。

赤队小组-代号1949(原CHT攻防小组)在这个瞬息万变的网络时代,我们保持初心,创造最好的社区来共同交流网络技术。您可以在论坛获取黑客攻防技巧与知识,您也可以加入我们的Telegram交流群 共同实时探讨交流。论坛禁止各种广告,请注册用户查看我们的使用与隐私策略,谢谢您的配合。小组成员可以获取论坛隐藏内容!

TheHackerWorld官方

精选回复

发布于

源码

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>


参考链接

创建帐户或登录后发表意见

最近浏览 0

  • 没有会员查看此页面。