All posts by Social marketing master

each listitem to open different activity

the code has listview and click on each item pops up alertdialog . alertdialog has two radio buttons “yes” ” no ” and then an “ok” button . when selected “yes” it takes to next activity , if selected “no” it stays in same activity . my problem is no matter which listitem I choose , i am taken to same ‘Next-activity’ . I want it to be taken to different activities depending on listitem chosen.

     listview = (ListView) findViewById(R.id.mylistview);
     final String[] items = new String[]{"IOS", "ANDROID", "WINDOWS"};
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_expandable_list_item_1, items);
     listview.setAdapter(adapter);

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

            int itemposition = position;

            String itemvalue = (String) listview.getItemAtPosition(position);
            final CharSequence[] items1 = {"yes", "no"};
            final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setTitle("slection confirmation");

            builder.setCancelable(false);
            builder.setSingleChoiceItems(items1, -1, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    selection = (String) items1[which];
                    Toast.makeText(getApplicationContext(), items1[which], Toast.LENGTH_SHORT).show();

                }
            });
            builder.setNeutralButton("OK",new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (selection)
                    {
                        case("yes"):
                            Intent myint=new Intent(MainActivity.this,secondpage.class);
                            myint.putExtra("act1","");
                            startActivity(myint);
                            break;
                        case("no"):
                            dialog.cancel();
                            break;
                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    });

}

read more

Two different ways to source scripts, two different outcomes (NameError: name is not defined.)

I have script that calls another script.

import sys
if "script_path" not in sys.path:
    sys.path.insert(0,"script_path")
import script_name

script_name.functionCall()

This works all well and good, the function is successfully called. However, later on in the script, if I call another function, I get NameError: name function is not defined. But it is. Clear as day.

read more

Symfony2 Twig and Controller cache

I have a problem with environments about cache.

When I modified a Twig, I view this modification on DEV and I need clear cache for see this change on Prod. This is correct.

But when I modified a Controller, I view this modification on DEV and on PROD too, without clear cache.

I have this configuration on files:

app.php

$kernel = new AppKernel('prod', false);

app_dev.php

$kernel = new AppKernel('dev', true);

Symfony2 Twig and Controller cache

Symfony2 Twig and Controller cache

I have a problem with environments about cache.

When I modified a Twig, I view this modification on DEV and I need clear cache for see this change on Prod. This is correct.

But when I modified a Controller, I view this modification on DEV and on PROD too, without clear cache.

I have this configuration on files:

app.php

$kernel = new AppKernel('prod', false);

app_dev.php

$kernel = new AppKernel('dev', true);

Symfony2 Twig and Controller cache