-3

I got this inside a method

    View android = inflater.inflate(R.layout.asd_frag, container, false);
    ((TextView) android.findViewById(R.id.textViewAsd01)).setText("asd");
    return android;
    View android02 = inflater.inflate(R.layout.asd02_frag, container, false);
    ((TextView) android.findViewById(R.id.textViewAsd02)).setText("asd02");
    return android02;

So the problem is that you cannot return 2 return statements inside a method, does someone know a trick to make this happen.

Mr x
  • 1
  • 1
  • There are no tricks. You can't return more than one object from a method. My guess is that your fundamental design is broken. What are you trying to achieve? You'll need to provide more code and a better explanation. – Kon Jul 21 '15 at 21:04
  • 2
    create a class that can hold multiple Views (or use an existing one, like `List` -- depending on your use case) and return an instance of that – yshavit Jul 21 '15 at 21:04
  • If you need to return both views, you could return them together as an array or list - but I wonder whether these two things should just be called two separate times in a slightly different method setup. – DoubleDouble Jul 21 '15 at 21:08
  • Ok so I created an array View[] android = new View[6]; android[0] = inflater.inflate(R.layout.asd_frag, container, false); android[0] = inflater.inflate(R.layout.asd_frag, container, false); but my return doesnt work properly: return android – Mr x Jul 21 '15 at 21:19

1 Answers1

0

Create a custom object which will contain the 2 values or use Pair.create(a, b)

BladeCoder
  • 12,779
  • 3
  • 59
  • 51