-2

I am new in android development. I am working on an app that is supposed to be function by long pressing any of the text or image file. For example when we long press any text or image it ask us for different options like copy, cut etc. when we select any of it, that particular work is performed. so, i want to add my application's name with that option so that when my application is called it performs the desired action. I will be thank full if some one helps.

kdubey007
  • 310
  • 3
  • 4
  • 9

2 Answers2

0

You just have to set a longClickListener on the desired view :

ImageView iv = (ImageView) findViewById(R.id.ImageView);
iv.setOnLongClickListener(vlong);

private View.OnLongClickListener vLong = new View.OnLongClickListener() {
    public boolean onLongClick(View view) {
        // do any thing
        return true;
    }
};
Helix
  • 1,024
  • 8
  • 14
  • I think you didnot got what my query was. I actually want this to be happened from some other app or gallery or message box text. – kdubey007 Jun 11 '14 at 14:28
  • My mistake, if you want your application to deal with a specific kind of files, you should look at the [intent filter in the manifest](http://stackoverflow.com/questions/3760276/android-intent-filter-associate-app-with-file-extension) – Helix Jun 11 '14 at 14:36
  • i searched it but intent filter is not working for my application or might be i didnot got it exactly. please help me, I'll be thank full. – kdubey007 Jun 11 '14 at 14:39
  • [This](https://github.com/paulmach/Text-Edit-for-Android/blob/master/AndroidManifest.xml) intent filter is working for me. We will need your manifest if you need more help. – Helix Jun 11 '14 at 14:48
0

imageview or textview or else ,use setOnLongClickListener,while clicking long-press you would initiate any popup window or layout inflation.it works fine.

ImageView iv = (ImageView) findViewById(R.id.ImageView);
i.setOnLongClickListener(new OnLongClickListener() { 
        @Override
        public boolean onLongClick(View v) {
            // TODO Auto-generated method stub
            // popupwindow();
             layout_inflater()
            return true;
        }
    });

public void layou_inflator()
{
 //Do your stuff
}
learner
  • 2,883
  • 2
  • 18
  • 31