Will accept to all! There were tasks to implement the program on Android, something like a converter. So far, what is given is not easy, but the sample implementation of the calculator was less successful. The question is the following if someone sketched the source code of the application, which has a list of "calculation types" and when clicked on the calculation, switched to a new canvas with a certain number of fields (required for input). The maximum number of fields for input: 3. I found a source on the Internet called "AndroidListView". There is a list of titles, when you switch to which a detailed page appears, however this is one page for each item in the list, the name changes. I tried to adapt to this logic, but it was not there. I created 3 fields and wanted to hide the 3rd field by default (for some calculations only 2 are required) and got stuck with it. The application just crashes. Does anyone have sketches or ideas on how to get out of this situation? Thank you all for your attention. Listing below:

public class AndroidListViewActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // storing string resources into Array String[] adobe_products = getResources().getStringArray(R.array.adobe_products); // Binding Array to ListAdapter this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products)); ListView lv = getListView(); // listening to single list item on click lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EditText InputС = (EditText) findViewById(R.id.InputC); InputС.setVisibility(View.VISIBLE); //Toast.makeText(getBaseContext(), "tabId = " + , Toast.LENGTH_SHORT).show(); // selected item String product = ((TextView) view).getText().toString(); // Launching new Activity on selecting single List Item Intent i = new Intent(getApplicationContext(), SingleListItem.class); // sending data to new activity i.putExtra("product", product); startActivity(i); } }); } } 
  • 2
    Something is not clear logic, that for EditText when clicking on the item's list? How should this work? - pavlofff

1 answer 1

I am confused in your terms: "page", "canvas", "type of calculation". I understand you have a ListView , when you click on its item, you need to switch to another Activity and, depending on the item selected, hide (or not hide) one of the EditText ?


Is this, I suppose, your code? Which should make EditText visible on the new canvas?

 EditText InputС = (EditText) findViewById(R.id.InputC); InputС.setVisibility(View.VISIBLE); 

Then it is not surprising that the application falls. It needs to be done in SingleListItem

  Intent i = new Intent(getApplicationContext(), SingleListItem.class); i.putExtra("product", product); i.putExtra("isVisible", true); //нужно ли показать startActivity(i); 

In SingleListItem , in Oncreate() get data

 EditText InputС = (EditText) findViewById(R.id.InputC); boolean isVisible = getIntent().getBooleanExtra("isVisible", false); if(isVisible){ InputС.setVisibility(View.VISIBLE); } 
  • Yes, you understood me correctly. However, apparently I misunderstood you. I did not succeed in hiding the field. If you have a couple of minutes, could you not give your contact details (Skype, ICQ ...?) - node_pro
  • At the same time, something I'm not doing so the phone hangs - node_pro