标签: android-widget

如何设置Android菜单xml文件中定义的菜单项的意图?

如何设置Android菜单xml文件中定义的菜单项的意图?例如,我目前有......

<menu xmlns:android="http://schemas.android.com/apk/res/android" android:name="Main Menu">
    <item android:title="@string/resume_game" android:icon="@drawable/resume"></item>
    <item android:title="@string/play_golf" android:icon="@drawable/play_golf"></item>
    <item android:title="@string/my_rounds" android:icon="@drawable/my_rounds"></item>
</menu>
Run Code Online (Sandbox Code Playgroud)

在我的活动中,我有以下方法覆盖...

   @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.main_menu, menu);
        final MenuItem menuItem = (MenuItem) menu.findItem(R.id.about_item);

        return true;
    }
Run Code Online (Sandbox Code Playgroud)

android android-widget

0
推荐指数
1
解决办法
4630
查看次数

我在哪里可以找到Power Control Widget源码安卓?

我在哪里可以找到以下链接

07-26 11:32:31.865: VERBOSE/MAKIService(1081): Received Broadcast:android.intent.action.START_TETHER
07-26 11:32:31.865: VERBOSE/MAKIService(1081):         DataString:null
07-26 11:32:31.865: VERBOSE/MAKIService(1081):           toString:Intent { act=android.intent.action.START_TETHER }
Run Code Online (Sandbox Code Playgroud)

我需要使用这一个用于我的蓝牙系绳启用.虽然按下电源小部件系绳按钮我在我的日志上观察到这一个.我在哪里可以找到MAKIService?

至少给我一个Power Control Widget的代码链接.这可以从Android 1.6开始提供吗?

android android-widget

0
推荐指数
1
解决办法
3159
查看次数

操作栏上的Android 3.0蜂窝搜索视图

如何在蜂窝的操作栏上设置"搜索项"?如果可能,请提供完整的布局代码.

android android-widget android-actionbar

0
推荐指数
1
解决办法
3670
查看次数

Android在运行时在图标上显示数字

我想在我的应用程序中显示图标上的数字.这些数字将在运行时出现.如图所示.请帮助,我如何在Android中实现这一点.

ICON图片

图标

icons android drawable android-widget

0
推荐指数
1
解决办法
722
查看次数

如何获取android中两个EditText的同时值?

我想将Edittext设置为,无论我写什么并输入EditText,它都应该在同一时刻写入TextView.

我认为可以通过添加任何istener来实现.我无法实现它.所以请任何人帮助我.?谢谢.

 includedText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

                if(!(includedText.getText().toString().equals("")))
                {
                    double included = Double.parseDouble(includedText.getText().toString());
                    included = roundTwoDecimals(included);
        //          double amountValue = (excluded*15/100);

                    String amt = String.valueOf(roundTwoDecimals(included-(included/1.15)));
                    String excluded = String.valueOf(included/1.15);
                    System.out.println("The Amount is: "+amt);
                    amountText.setText(amt);
                    try{
                        excludedText.setText(excluded); //////// Error
                    }
                    catch(Exception e)
                    {
                        e.printStackTrace();
                    }
                }
                else
                {
                    amountText.setText("");
                    //excludedText.setText("");
                }

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        @Override …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-layout

0
推荐指数
1
解决办法
579
查看次数

带有线程的Android ProgressBar

我正在使用android中的ProgressBar类,但是我无法在5秒内完成它并加载应用程序.一切正常但进度条没有进展.这是代码.

public class StartPoint extends Activity{

ProgressBar progressBar;
private int progressBarStatus = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    progressBar = (ProgressBar)findViewById(R.id.progressBar1);


    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(5000);
                while(progressBarStatus < 5000){
                    progressBar.setProgress(progressBarStatus);
                    progressBarStatus += 1000;

                }
            }catch(InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent openMainList = new Intent(StartPoint.this, in.isuru.caf.MainList.class);
                startActivity(openMainList);
            }
        }
    };
    timer.start();
}

protected void onPause(){
    super.onPause();
    finish();
}

}
Run Code Online (Sandbox Code Playgroud)

这是布局文件splash.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-progressbar

0
推荐指数
1
解决办法
6138
查看次数

请提供Android错误消息说明

有人可以解释下面的错误信息是什么意思吗?错误是:

java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.TextView
Run Code Online (Sandbox Code Playgroud)

android android-widget android-intent android-layout

0
推荐指数
1
解决办法
1907
查看次数

setAlpha出错

嗨伙计们,因为这个错误我需要你的帮助:

这是logcat:

07-30 16:12:33.823: E/AndroidRuntime(21283): java.lang.NoSuchMethodError: android.widget.LinearLayout.setAlpha
07-30 16:12:33.823: E/AndroidRuntime(21283):    at it.bisemanuDEV.piano.livello1$1.onClick(livello1.java:393)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at android.view.View.performClick(View.java:2408)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at android.view.View$PerformClick.run(View.java:8819)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at android.os.Handler.handleCallback(Handler.java:603)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at android.os.Looper.loop(Looper.java:123)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at android.app.ActivityThread.main(ActivityThread.java:4627)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at java.lang.reflect.Method.invokeNative(Native Method)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at java.lang.reflect.Method.invoke(Method.java:521)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-30 16:12:33.823: E/AndroidRuntime(21283):    at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

android android-widget android-layout

0
推荐指数
1
解决办法
2914
查看次数

复选框无法正常工作

我有一个复选框和一个textView,当选中复选框时,textview应显示该复选框被按下.但是当我运行我的代码时,我得到一个nullpointerexception.这是我的代码:

public class MyActivity extends Activity {

public void onCreate(Bundle savedInstanceState) {
    CheckBox android=(CheckBox)findViewById(R.id.android);
    CheckBox ios=(CheckBox)findViewById(R.id.ios);
    CheckBox webos=(CheckBox)findViewById(R.id.webos);
    CheckBox windows=(CheckBox)findViewById(R.id.windows);
    Button generate=(Button)findViewById(R.id.generate);
    final TextView result=(TextView)findViewById(R.id.result);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    android.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(((CheckBox)view).isChecked())
                result.setText("Android Checked");
        }
    });

   }
  }
Run Code Online (Sandbox Code Playgroud)

这是我的问题所在的logcat的一部分:

12-21 17:25:00.324: ERROR/AndroidRuntime(960): FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.GridAndroid/com.example.GridAndroid.MyActivity}: java.lang.NullPointerException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
    at android.app.ActivityThread.access$600(ActivityThread.java:130)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) …
Run Code Online (Sandbox Code Playgroud)

android android-widget android-layout

0
推荐指数
1
解决办法
823
查看次数

ToggleButton每个棒棒糖

我希望我的ToggleButton像这样. 在Lollipop中切换

但是使用此代码,它始终显示较旧的切换按钮. 在此输入图像描述

我只使用API​​ 21在Emulator中运行代码,我在这里遗漏了一些东西.我的代码片段是

   <ToggleButton

            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

android android-widget android-layout

0
推荐指数
1
解决办法
2037
查看次数