2012-02-15 59 views
0

我正在做一個Android應用程序,用戶將能夠在屏幕上拖放按鈕,然後從那裏捕獲該圖像並將其發送給我。我得到了拖放,我得到了圖片上傳,現在我只需要從設備上獲取重新定位按鈕的屏幕截圖,而無需使用DDM。這裏是我的MainActivity安卓拖放捕獲屏幕完成

public class DragSymbols extends Activity { 


      // Define the symbols and their initial coordinates in arrays. No limit in principle 
      // to how many. Coordinates are measured from the upper left corner of the screen, 
      // with x increasing to the right and y increasing downward 



      float [] X = {2, 2, 2, 2, 2, }; // Initial x coord in pixels of upper left corner of symbol 
      float [] Y = {2, 2, 2, 2, 2, };  // Initial y coord in pixels of upper left corner of symbol 

      // The Drawable corresponding to the symbol. R.drawable.file refers to file.png, .jpg, 
      // or .gif stored in res/drawable-hdpi (referenced from code without the extension). 


      // 5 Buttons in Total 
      int[]symbolIndex = {R.drawable.twit,R.drawable.twit, R.drawable.twit,R.drawable.twit,R.drawable.twit,}; 

      // Instantiate a SymbolDragger instance (which subclasses View), passing to it in the 
      // constructor the context (this) and the above arrays. Then set the content view to 
      // this instance of SymbolDragger (so the layout is being specified entirely by SymbolDragger, 
      // with no XML layout file). The resulting view should then place draggable symbols with 
      // content and initial position defined by the above arrays on the screen. 

      SymbolDragger view = new SymbolDragger(this, X, Y, symbolIndex); 
      view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 
       ViewGroup.LayoutParams.FILL_PARENT)); 
      setContentView(view); 
     } 
    } 

回答

1

從我能理解你想採取一旦你的應用程序的屏幕截圖拖放完成。對於這個U可以去throgh以下鏈接可重定向你在正確的方向

http://coderzheaven.com/2011/10/how-to-take-screenshot-of-your-phone-in-android-through-code/

http://coderzheaven.com/2011/10/how-to-create-screenshot-of-application-and-store-it-in-sdcard/

希望這有助於。

+0

我知道是在那裏,我只是不記得我在哪裏看到它,謝謝百萬德瓦 – KaSiris 2012-02-15 07:38:20

+0

好吧我已經試圖實現上述代碼的4種不同方式的拍攝屏幕截圖,項目是乾淨的,拖放項目正在顯示,但我的主要佈局不是......任何線索爲什麼?或者我如何捕獲屏幕截圖...也許運行後臺線程? :0 – KaSiris 2012-02-15 08:20:46

+0

從昨天開始嘗試......沒有任何工作。 – KaSiris 2012-02-16 09:09:01