Skip to content
Snippets Groups Projects
Commit d5073438 authored by Aldyaka Mushofan's avatar Aldyaka Mushofan
Browse files

sudah dynamic

parent 24cb10cf
Branches
No related merge requests found
package tugas.sister.sisterclient;
import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import org.json.JSONException;
import org.json.JSONObject;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class TradeBoxActivity extends Activity {
JSONObject request, response;
public TableLayout tradeItem;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trade_box);
tradeItem = (TableLayout)findViewById(R.id.tab_content);
fillItemTable();
}
public void onTradeBoxResult(String token) throws JSONException {
request = new JSONObject();
request.put("method","tradebox");
request.put("token", token);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_trade_box, menu);
return true;
}
public void onFetchItemResult(String token, String offer_token) throws JSONException {
request = new JSONObject();
request.put("method","fetchitem");
request.put("token",token);
request.put("offer_token", offer_token);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onCancelOfferResult(String token, String offer_token) throws JSONException {
request = new JSONObject();
request.put("method","canceloffer");
request.put("token",token);
request.put("offer_token", offer_token);
private void fillItemTable(){
TableRow row;
TextView text1, text2, text3, text4, text5;
//konversi ke satuan dip
int dip = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 1, getResources().getDisplayMetrics());
int a = TradeItem.item1.length;
for(int i = 0; i < a; i++){
row = new TableRow(this);
text1= new TextView(this);
text2 = new TextView(this);
text3 = new TextView(this);
text4 = new TextView(this);
text5 = new TextView(this);
text1.setText(TradeItem.item1[i]);
text2.setText(TradeItem.amount1[i]);
text3.setText(TradeItem.item2[i]);
text4.setText(TradeItem.amount2[i]);
text5.setText("Fetch");
text1.setTextSize(15);
text2.setTextSize(15);
text3.setTextSize(15);
text4.setTextSize(15);
text5.setTextSize(15);
text1.setWidth(60*dip);
text2.setWidth(60*dip);
text3.setWidth(60*dip);
text4.setWidth(60*dip);
text5.setWidth(60*dip);
row.addView(text1);
row.addView(text2);
row.addView(text3);
row.addView(text4);
row.addView(text5);
tradeItem.addView(row, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment