Guest User

Untitled

a guest
Nov 14th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. @Override
  2. public View onCreateInputView() {
  3. final File imagesDir = new File(getFilesDir(), "images");
  4. RelativeLayout KeyboardLayout = (RelativeLayout) getLayoutInflater().inflate(R.layout.keyboard_layout, null);
  5. LinearLayout ImageContainer = (LinearLayout) KeyboardLayout.findViewById(R.id.imageContainer);
  6.  
  7. LinearLayout ImageContainerColumn = (LinearLayout) getLayoutInflater().inflate(R.layout.image_container_column, ImageContainer, false);
  8.  
  9. for (int i = 0; i < rawFiles.length; i++) {
  10. System.out.println(i);
  11. if ((i % 2) == 0) {
  12. ImageContainerColumn = (LinearLayout) getLayoutInflater().inflate(R.layout.image_container_column, ImageContainer, false);
  13. }
  14.  
  15. // Creating button
  16. ImageButton ImgButton = (ImageButton) getLayoutInflater().inflate(R.layout.image_button, ImageContainerColumn, false);
  17. ImgButton.setImageResource(getResources().getIdentifier(rawFiles[i], "raw", getPackageName()));
  18. ImgButton.setTag(rawFiles[i]);
  19. ImgButton.setOnClickListener(new View.OnClickListener() {
  20. @Override
  21. public void onClick(View view) {
  22. String emojiName = view.getTag().toString().replaceAll("_", "-");
  23.  
  24. final File file = getFileForResource(ImageKeyboard.this, getResources().getIdentifier(view.getTag().toString(), "raw", getPackageName()), imagesDir, "${view.getTag().toString()}.png");
  25. ImageKeyboard.this.doCommitContent("A ${emojiName} logo", MIME_TYPE_PNG, file);
  26. }
  27. });
  28.  
  29. ImageContainerColumn.addView(ImgButton);
  30.  
  31. if ((i % 2) == 0) {
  32. ImageContainer.addView(ImageContainerColumn);
  33. }
  34. }
  35. return KeyboardLayout;
  36.  
  37.  
  38. }
Add Comment
Please, Sign In to add comment