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

-1

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

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 did not succeed.

    
asked by anonymous 16.10.2017 / 14:57

1 answer

0

Apparently in your code you are setting setContentView to another Activity that is not within your Intent .

Yours:

setContentView(R.layout.activity_widget_configure_1);

And you're trying to start:

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;

For you seem to be in the activity_widget_configure_1 layout and not WidgetConfigureActivity . With this you can not start another activity from another that is not yet started.

    
16.10.2017 / 15:42