Created
November 1, 2017 00:22
-
-
Save wuerges/154d35127c8722f72e8f2218e4250074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.aluno_uffs.myapplication; | |
import android.content.Intent; | |
import android.support.annotation.NonNull; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.ArrayAdapter; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.ListView; | |
import android.widget.TextView; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.ListIterator; | |
//class MeuListener implements View.OnClickListener { | |
// | |
// ArrayAdapter adapter; | |
// | |
// MeuListener(ArrayAdapter<String> adapter) { | |
// this.adapter = adapter; | |
// } | |
// | |
// @Override | |
// public void onClick(View v) { | |
// adapter.add("Sim, claro!"); | |
// } | |
//} | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
ListView lista = findViewById(R.id.lista); | |
Button button = findViewById(R.id.adicionar); | |
ArrayList<String> meuArray = new ArrayList<String>(); | |
final ArrayAdapter<String> adapter = | |
new ArrayAdapter<String>(this, | |
android.R.layout.simple_list_item_1, meuArray); | |
adapter.add("oi"); | |
adapter.add("tudo bem?"); | |
lista.setAdapter(adapter); | |
//MeuListener listener = new MeuListener(adapter); | |
button.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
adapter.add("Sim, claro!"); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment