0

MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
myList.create(this, R.id.mylist)
...
}

MyList.java

public void create(Activity activity, int id)
{
...
CustomAdapter adapter = new CustomAdapter(activity, R.layout.someTextView, 
someVector);
...
}

CustomAdapter.java

@Override
public View getView(int position, View view, ViewGroup parent) {
...
EditText tx = view.findViewsWithText(R.id.someTextView);
...
}

If I try get EditText from another layout someTextView.xml where is only EditView i have error

Error inflating class EditText

I tried clean/rebuild my project I've tried method from this thread:

enter link description here but it not work for my case

I saw in other threads that it can be problem with this line in build.gradle

classpath 'com.android.tools.build:gradle:3.3.0'

but it was with 2.2-alpha (downgrade to 2.1)

How can I get access to EditText from another layout?

21koizyd
  • 1,843
  • 12
  • 25

2 Answers2

0

You have to inflate the layout first and then get your EditText from that view.

  v = LayoutInflater.from(getContext()).inflate(R.layout.someTextView, parent, false);
    EditText myEditText = (EditText )v.findViewById( R.id.my_edit_text);
Ravi
  • 881
  • 1
  • 9
  • 23
  • Unfortunately it is not the reason, I had check `if(view == null)` that run firt line of your code, but problem still is not solved. – 21koizyd Mar 09 '19 at 00:15
0
EditView tx = view.findViewsWithText(R.id.someTextView);
Longalei
  • 453
  • 3
  • 8
  • While this code may solve the question, [including an explanation](https://meta.stackexchange.com/questions/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply. – Pika Supports Ukraine Mar 27 '19 at 03:26
  • @PikachuthePurpleWizard Don't get excited. Complex problems deserve more explanation. sometimes, talk is cheap, show the code would be better.Obviously, your comment is cheap and meaningless. – Longalei Mar 27 '19 at 06:23