Hello everyone.
I have this code in java, and I tired to convert it to android, but it dose won't to work:
public ShopPhone() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); tF = new JTextField(); contentPane.add(tF, BorderLayout.NORTH); tF.setColumns(10); tF.setText(""); JButton btnNewButton = new JButton("New button"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(tF.getText().equals("x")){ x = "5733689997"; } JOptionPane.showMessageDialog(null, x); } }); contentPane.add(btnNewButton, BorderLayout.SOUTH); } }
and this my code for the android:
public class MainActivity extends ActionBarActivity { public EditText search; public TextView print; public Button bFind; protected String name; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } search = (EditText) findViewById(R.id.find); print = (TextView) findViewById(R.id.show); bFind = (Button) findViewById(R.id.press); bFind.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(search.getText().equals("name")){ name = "horyah"; } print.setText(name); } }); }
can anyone tell me what am I doing wrong. please help
Thank you.