0

I want to show pop-up windows when the client choose one item from the list item. for now my codes works like this, when i click one item it will direct to new layout that show the link for download.
What i wanna ask, how to make my DownloadText class become pop-up window? so the client can see the link without move to other layout?
anyone, please help me how to do it. thank you very much

DownloadDetail.java - this one is for show the list item

public class DownloadDetail extends ListActivity {
public Koneksi linkurl;

    String SERVER_URL;
    private RSSFeed myRssFeed = null;

    public class MyCustomAdapter extends ArrayAdapter<RSSItem> {

        public MyCustomAdapter(Context context, int textViewResourceId,
                List<RSSItem> list) {
            super(context, textViewResourceId, list);   
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            //return super.getView(position, convertView, parent);

            View row = convertView;

            if(row==null){
                LayoutInflater inflater=getLayoutInflater();
                row=inflater.inflate(R.layout.rss_row, parent, false);  
            }

            TextView listTitle=(TextView)row.findViewById(R.id.juduldl);
            listTitle.setText(myRssFeed.getList().get(position).getTitle());
            /*TextView listPubdate=(TextView)row.findViewById(R.id.status);
            listPubdate.setText(myRssFeed.getList().get(position).getPubdate());*/

            return row;
        }
    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rss);

        Bundle bundle = this.getIntent().getExtras();

        String param1 = bundle.getString("keyIdc");
        String param2 = bundle.getString("keyUserId");


        SERVER_URL = SERVER_URL+"?idc="+param1+"&un="+param2;
        try {
            linkurl = new Koneksi(this);
            SERVER_URL = linkurl.getUrl();
            SERVER_URL += "/mobile/DownloadDetail.php?idc="+param1+"&idu="+param2;
            URL rssUrl = new URL(SERVER_URL);
            SAXParserFactory mySAXParserFactory = SAXParserFactory.newInstance();
            SAXParser mySAXParser = mySAXParserFactory.newSAXParser();
            XMLReader myXMLReader = mySAXParser.getXMLReader();
            RSSHandler myRSSHandler = new RSSHandler();
            myXMLReader.setContentHandler(myRSSHandler);
            InputSource myInputSource = new InputSource(rssUrl.openStream());
            myXMLReader.parse(myInputSource);

            myRssFeed = myRSSHandler.getFeed();

        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        if (myRssFeed!=null)
        {
            TextView feedTitle = (TextView)findViewById(R.id.feedtitle);
            TextView feedDescribtion = (TextView)findViewById(R.id.feeddescription);
            TextView feedPubdate = (TextView)findViewById(R.id.feedPubdate);
            TextView feedLink = (TextView)findViewById(R.id.feedlink);
            feedTitle.setText(myRssFeed.getTitle());
            feedDescribtion.setText(myRssFeed.getDescription());
            feedPubdate.setText(myRssFeed.getPubdate());
            feedLink.setText(myRssFeed.getLink());

            /*ArrayAdapter<RSSItem> adapter = 
                new ArrayAdapter<RSSItem>(this,
                        android.R.layout.simple_list_item_1,myRssFeed.getList());
            setListAdapter(adapter);*/
            MyCustomAdapter adapter =
                    new MyCustomAdapter(this, R.layout.rss_row, myRssFeed.getList());
                setListAdapter(adapter);
        }
    }


    protected void onListItemClick(ListView l, View v, int position, long id) {

        Intent intent = new Intent(this,DownloadText.class);
        Bundle bundle = new Bundle();
        bundle.putString("keyNama", myRssFeed.getItem(position).getTitle());
        bundle.putString("keyReference", myRssFeed.getItem(position).getDescription());
        bundle.putString("keyIdc", myRssFeed.getItem(position).getLink());
        intent.putExtras(bundle);
        startActivity(intent);
    }
}

DownloadText.java - this codes for show the links

public class DownloadText extends Activity{
    public Koneksi linkurl;
    public Kondownload linkurl2;
    String url;
    String SERVER_URL;
    String SERVER_URL2;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.linkdownload);

        TextView mTextLink = (TextView) findViewById(R.id.LinkDownload);
        Bundle bundle = this.getIntent().getExtras();

        String param1 = bundle.getString("keyIdc");
        String param2 = bundle.getString("keyReference");
        if(param2.endsWith(".pdf"))
        {
            linkurl = new Koneksi(this);
            SERVER_URL = linkurl.getUrl();
            SERVER_URL += "/moodledata/"+param1+"/"+param2;
            mTextLink.setText(SERVER_URL);
            Pattern pattern = Pattern.compile(SERVER_URL);
           Linkify.addLinks(mTextLink, pattern, "");

        }
        else
        {
            linkurl2 = new Kondownload(param2);
            SERVER_URL2 = linkurl2.getUrl();
            mTextLink.setText(SERVER_URL2);
            Pattern pattern = Pattern.compile(SERVER_URL2);
           Linkify.addLinks(mTextLink, pattern, "");
        }

    }
}

linkdownload.xml

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/AbsoluteLayout01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    tools:ignore="Deprecated" >

    <TextView
        android:id="@+id/Text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="6dip"
        android:layout_y="9dip"
        android:gravity="center"
        android:text="@string/silahkan_klik_link_di_bawah_ini_untuk_mengunduh_file"
        android:textColor="#000000"
        android:textSize="20dp"
        android:textStyle="bold" >
    </TextView>

    <TextView
        android:id="@+id/LinkDownload"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="6dip"
        android:layout_y="133dip"
        android:text="@string/ld" >
    </TextView>

</AbsoluteLayout>
blackneko
  • 91
  • 1
  • 12

2 Answers2

0

You can set your layout to dialog window.

    Dialog listDialog = new Dialog(activity);

            LayoutInflater li = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View v = li.inflate(R.layout.popover, null, false);
            listDialog.setContentView(v);
listDialog.show();
Brijesh Thakur
  • 6,768
  • 4
  • 24
  • 29
  • i put that code in DownloadText.java? O.o after this code `setContentView(R.layout.linkdownload);` ? thank you .. – blackneko Jun 19 '13 at 06:11
  • No On Click of List Item Create new Dialog. – Brijesh Thakur Jun 19 '13 at 06:20
  • but, when i click on list item. the item will redirect me to other class.. in that class i get the reference from bundle intent like that.. sorry I ask too much, because i'm beginner and got confused... O.o – blackneko Jun 19 '13 at 06:50
  • Why You are making DownloadText as an Activity. You can create a POJO and do your thing in that. You just open the dialog window with R.layout.linkdownload. and rest of the things pass to Constructor of the DownloadText class. – Brijesh Thakur Jun 19 '13 at 06:55
0

I guess you know what System.out.println(); does and how to check it?

Replace:

protected void onListItemClick(ListView l, View v, int position, long id) {
        System.out.println("item clicked!");
        Intent intent = new Intent(this,DownloadText.class);
        Bundle bundle = new Bundle();
        bundle.putString("keyNama", myRssFeed.getItem(position).getTitle());
        bundle.putString("keyReference", myRssFeed.getItem(position).getDescription());
        bundle.putString("keyIdc", myRssFeed.getItem(position).getLink());
        intent.putExtras(bundle);
        startActivity(intent);
    }

With:

protected void onListItemClick(ListView l, View v, int position, long id) {

        public Koneksi linkurl;
        public Kondownload linkurl2;
        String url;
        String SERVER_URL;
        String SERVER_URL2;
        String str_keyNama = null;
        String str_keyReference = null;
        String str_keyIdc = null;
        String str_link = null;


        str_keyNama =("keyNama", myRssFeed.getItem(position).getTitle().toString());
        str_keyReference =("keyReference", myRssFeed.getItem(position).getDescription().toString());
        str_keyIdc =("keyIdc", myRssFeed.getItem(position).getLink().toString());


        String param1 =  str_keyIdc;
        String param2 = str_keyReference;
        if(param2.endsWith(".pdf"))
        {
            linkurl = new Koneksi(this);
            SERVER_URL = linkurl.getUrl();
            SERVER_URL += "/moodledata/"+param1+"/"+param2;
            str_link = SERVER_URL.toString();
            System.out.println("SERVER_URL = "+str_link);
            //Pattern pattern = Pattern.compile(SERVER_URL);
            //Linkify.addLinks(mTextLink, pattern, "");

        }
        else
        {
            linkurl2 = new Kondownload(param2);
            SERVER_URL2 = linkurl2.getUrl();
            str_link = SERVER_URL2.toString();
            System.out.println("SERVER_URL2 = "+str_link);
           //Pattern pattern = Pattern.compile(SERVER_URL2);
           //Linkify.addLinks(mTextLink, pattern, "");
        }


    }
Bigflow
  • 3,616
  • 5
  • 29
  • 52
  • thank you very much for your help. the first link didn't appear. O.o .. oh by the way what i want to do is when i click item, the pop up show in one activity(DownloadDetail.java), but i got confused ho am i supposed to do with codes in DownloadText.java and i must get the reference value from bundle like that. thank you very much – blackneko Jun 19 '13 at 11:00
  • @blackneko But why make a separate class for it then? isn't it easier to put the code of `DownloadText.java` into `DownloadDetail.java`? – Bigflow Jun 19 '13 at 11:13
  • because i can understand with it separate.. after several meeting with my lecturer, he said to make pop up window. and now i got confused to make listview with pop up window. if i put the pop up in on click listitem, where i must put the bundle for the value ? @_@ – blackneko Jun 19 '13 at 11:34
  • @blackneko Try to do the suggested code above. And tell me if `System.out.println();` gives any information in Logcat. (Check Logcat for message, nothing will appear on phone screen itself) – Bigflow Jun 19 '13 at 12:07
  • i get warning in "," and `myRssFeed` , myrss feed cannot be resolved, and for "," syntax error.. O.o – blackneko Jun 19 '13 at 12:33
  • I don't know why you get that, didn't change something on that, but got to go. cya tomorrow, sorry – Bigflow Jun 19 '13 at 12:46
  • Bigflow, thank you very much for your help your codes give me idea :D.. I already found the solution...thank you very much – blackneko Jun 22 '13 at 11:51
  • Bigflow, may I ask for your help again? I really need help, the chat already success can show the messages from other party. but here i have problem that I don't understand. i want to make the name from other party show up, but when i do that, it only appear the first name and after that it got force close. if you have time, i really need help to look at this problem [link]http://stackoverflow.com/questions/17249656/unable-to-show-friends-name-on-chat thank you very much – blackneko Jun 22 '13 at 11:54