Is it possible to create a Widget with multiple configuration screens?

Asked

Viewed 52 times

-1

I have a Widget that there is only one configuration screen but want to add one more how can I do it? I know that the first screen that appears is a Activity try to open with Intent normal but not working.

I made this Intent:

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_widget_configure_1);

    final SharedPreferences Salvadados = getSharedPreferences(MontWidget, MODE_PRIVATE);

    ListView lista_teste = (ListView)findViewById(R.id.lista_teste);
    String[] dados = new String[]{"xxxx","xxxx","xxxxx"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dados);
    lista_teste.setAdapter(adapter);

    lista_teste.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            switch (position){
                case 0:

                    Intent nextConfig = new Intent(WidgetConfigureActivity.this, Widget_Configure_2.class);
                    startActivity(nextConfig);

                    finish();
                    break;

But I was unsuccessful.

  • Note that your code seems to have a syntax error, which is the lack of ; between sentences. Was that a mistake when pasting here or is your code really like this? If it is, this may be the reason why.

  • 1

    Are you sure that the name of the other Activity is Widget_configure_2 ???

  • Yes, that’s the name of the Activity I want to call

  • Well... apparently this was supposed to work. You can show the rest of your code ?

  • the next line is a Finish to close the screen and open the next

  • face the Finish is not to close the screen... the Finish is to terminate the application.. Remove it

  • Not it closes the Activity that is running and is in the widget the application nor this open I have already made the test commented the Finish and nothing happened

  • Then do what I told you... post your entire code for analysis

  • ready posted..

  • Check your layouts for the Activity Widget_configure_2 created in XML.

  • yes this maid

Show 6 more comments

1 answer

0

Apparently in your coddle you’re setting the setContentView for another Activity that is not within your Intent.

Your:

setContentView(R.layout.activity_widget_configure_1);

And you’re trying to starte:

Intent nextConfig = new Intent(WidgetConfigureActivity.this, Widget_Configure_2.class);

In this case the right one would be:

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_widget_configure_1);
    Context myContext = this;
    final SharedPreferences Salvadados = getSharedPreferences(MontWidget, MODE_PRIVATE);

    ListView lista_teste = (ListView)findViewById(R.id.lista_teste);
    String[] dados = new String[]{"xxxx","xxxx","xxxxx"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dados);
    lista_teste.setAdapter(adapter);

    lista_teste.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            switch (position){
                case 0:

                    Intent nextConfig = new Intent (myContext, Widget_Configure_2.class);
                    startActivity(nextConfig);

                    finish();
                    break;

'Cause apparently you’re on the layout activity_widget_configure_1 and not in the WidgetConfigureActivity. With this you can not start another Activity from another that is not even started.

  • face this does not work Widgetconfigureactivity.this is my activity context necessarily have to pass.

  • I did a little editing, try the test

  • with no result the same thing

  • Well... then I suggest checking your XML’s, because with the parameters passed he should start the new Activity.

  • I tried to call another Activity was good ta happening that right there it is not finding the screen that is to be opened

  • If you can’t find it, then she’s probably not raised

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.